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

Volker Wysk post at volker-wysk.de
Tue Oct 10 17:15:53 AEDT 2023


Am Dienstag, dem 10.10.2023 um 17:04 +1100 schrieb Julien Fischer:
> 
> 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).

Nice. Good to know. Thanks.

Volker


More information about the users mailing list