I'm trying to implement the nth permutation (nPr => per(n,L,Out)
) but I keep getting a false.
Here's what I'm trying to do;
per(0,_,[]).
per(_,[],[]).
per(R,[H|T1],[H|T]):-
R1 is R-1,
per(R1,T1,[H|T]),
per(R1,T1,T).
What am I doing wrong?
Also is there (an easier) way to implement nth permutation (nPr) using the built in permutation predicate?