Write a Prolog predicate my_permutation/2
that is true if and only if the 2 lists supplied are equal up to a permutation.
Make sure that the mode1 of your predicate is my_permutation(+,-)
, that is if the first argument is a fully instantiated list at call-time, a unbound variable as second argument would be unified with all the permutations of the list.
?- my_permutation([1, 3, 3, 7], Ans).
Ans = [1, 3, 3, 7] ;
Ans = [3, 1, 3, 7] ;
Ans = [3, 3, 1, 7] ;
Ans = [3, 3, 7, 1] ;
Ans = [1, 3, 3, 7] ;
Ans = [3, 1, 3, 7]
...