Created
December 18, 2014 15:07
-
-
Save barbolani/be0b5784bfb11c99ef44 to your computer and use it in GitHub Desktop.
Prolog - generate list permutations
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% Short permutation generator permutations(L,S) is true whenever S is a permutation | |
% of the elements of list L | |
permutations([],[]). | |
permutations( A, [R21 | X ] ) :- | |
append( L, [R21 | R22], A ), | |
append( L, R22, X2), | |
permutations( X2, X). |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment