title: Predicate for returning permutations of the order of elements a given list in prolog
body: <p>I'm trying to work out how this predicate in Prolog is working to produce permutations but I can't figure out the second predicate of sel - and was wondering whether this was clear to anyone else? </p>
  
  <pre><code>% permutation(L1, L2): L2 is a permutation of L1                   
  
  permutation([], []).
  permutation(L1, [X|Y]):-
     sel(L1, X, T),
     permutation(T, Y).
  
  sel([X|Y], X, Y).
  sel([X|Y], Z, [X|T]):-
     sel(Y, Z, T).
  </code></pre>