[m-users.] Cartesian product of two sets of things.

Julien Fischer jfischer at opturion.com
Tue Oct 10 17:04:47 AEDT 2023



On Mon, 9 Oct 2023, Volker Wysk wrote:

> Am Montag, dem 09.10.2023 um 11:04 +0200 schrieb Volker Wysk:
>> :- pred cart_prod(set(T)::in, set(U)::in, set(pair(T, U))::out) is det.
>
> Oops, that should be:
>
> :- pred cart_prod(set(T)::in, set(U)::in, list(pair(T, U))::out) is det.

Either that, or you should call solutions_set:

cart_prod(Set1, Set2, Res) :-
     solutions_set(
         (pred((A - B)::out) is nondet :-
             set.member(A, Set1),
             set.member(B, Set2)
         ),
         Res).

Julien.


More information about the users mailing list