0 Replies - 275 Views - Last Post: 09 April 2009 - 07:51 AM

#1 mostyfriedman   User is offline

  • The Algorithmi
  • member icon

Reputation: 729
  • View blog
  • Posts: 4,473
  • Joined: 24-October 08

finding all permutations of a list(PROLOG)

Posted 09 April 2009 - 07:51 AM

Description: a snippet that lists all the possible permutations of a list
delete(X, [X|T], T).

delete(X, [H|T], [H|S]):-
	delete(X, T, S).


permutation([], []).

permutation([H|T], R):-
	permutation(T, X), delete(H, R, X).

Is This A Good Question/Topic? 0
  • +

Page 1 of 1