my perm/2 is not commutative



Hello!

I have written a permutation relation that is like this:

perm([],[]).
perm(L,[A|B]):- insert(A,X,L), perm(X,B).


It works in one direction:
perm([1,2,3],X).

but not in this direction:
perm[X,[1,2,3]).

....then it will produce one solution and enter an eternal loop.

How can I write my perm relation more general?


/Anders


.