What is permutation/2 ?
As said in the help(permutation).
:
The predicate permutation/2
is primarily intended to generate permutations.
That's what I want to use it for.
How permutation/2 should work
This is the example given in the documentation: (Of course, the box around does not exist normally.)
____________________________________________________________________| |
| ?- permutation([1,2], [X,Y]). |
| X = 1, Y = 2 ; |
| X = 2, Y = 1 ; |
||false.____________________________________________________________ ||
Reproducing the example (and several other examples)
When I try permutation/2
, not the same happens: (any of these are run on my computer)
?- permutation([1,2],[X,Y]).
X = 1,
Y = 2 .
?- permutation([2,1],X).
X = [2, 1] .
?- permutation([1,2],[2,1]).
true .
As you can see, prolog doesn't return any permutation but the input itself.
- Why is this happening?
- And how to get all permutations?
More details on my prolog version.
- On my Ubuntu/Linux computer
- I installed the package
swipl
just yesterday - it tells me it's version:
threaded, 64 bits, version 7.4.2