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
(defn move-to-front [first others] | |
"Moves an item to the front of the list" | |
(cons first (remove #(identical? first %) others))) | |
(defn first-level [list] | |
"Returns a list of all first-level permutations." | |
(map #(move-to-front % list) list)) | |
(defn permute-deeper [depth list] | |
"Takes a list and a depth. Ignores the first few items according to the depth, and returns a list of all permutations for the rest." | |
(let [head-of-list (take depth list) | |
rest-of-list (drop depth list) |