-
-
Save amalloy/8367369 to your computer and use it in GitHub Desktop.
Revisions
-
amalloy revised this gist
Jan 11, 2014 . 2 changed files with 9 additions and 21 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,9 @@ (defn permx [coll] (letfn [(helper [m] (if (empty? m) '(()) (for [[i x] m perm (helper (dissoc m i))] (cons x perm))))] (helper (into (sorted-map) (map-indexed vector coll))))) This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,21 +0,0 @@ -
kpmaynard created this gist
Jan 11, 2014 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,21 @@ (defn weave ([a-seq] (weave (first a-seq) (rest a-seq))) ([x a-seq] (defn weave-helper [x a-seq acc n] (println "In weave: Sequence is: " a-seq) (cond (nil? a-seq) (cons x '()) (<= n (count a-seq)) (weave-helper x a-seq (cons (concat (take n a-seq) (cons x (drop n a-seq))) acc) (inc n)) :else acc )) (weave-helper x a-seq '() 0))) (defn permx [a-seq] (if (nil? a-seq) nil (map #(weave (first a-seq) %) (permx (rest a-seq)))))