Thanks Very Much. I tried to run your code but did not work. I tried to modify it a bit and it finally it worked.
cartesian_product([H|T],B):- cartesian_product_1(H,B),
nl,cartesian_product(T,B).
cartesian_product_1(H,[]).
cartesian_product_1(H,[H1|T1]):- write(H),
write(H1),write('...
I was working on the following problem:
The Cartesian Product of two sets is the set containing all the tuples produced from one element of one set and second element from the other set. Consider the sets A = {a, b, c} and B = {1, 2, 3}
The cartesian product of A and B = A ? B
= {...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.