Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (defn perms [bag]
- "Gets all permutations in a bag of items. Assumes they are distinct"
- (lazy-seq
- (if (empty? bag) '(())
- (mapcat (fn [x]
- (map #(cons x %) (perms (remove #(= x %) bag)))) bag))))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement