permutations of a sequence
The permutations of a sequence are all of the sequences with the same elements but in different orders. Here are some examples.
The permutations of [1, 2]
are [1, 2]
and [2, 1]
.
The permutations of [1, 2, 3]
are [1, 2, 3]
, [1, 3, 2]
, [2, 1, 3]
, [2, 3, 1]
, [3, 1, 2]
, and [3, 2, 1]
.
The number of permutations grows really fast with the size of the list.
Your challenge is to write a function that generates all permutations of a list. Your function should return a lazy sequence.
Note: there already is a great, fast implementation of this function in clojure.math.combinatorics