When the pupil is ready to learn, a teacher will appear.
(defn subsets-by-card [s] (reduce (fn [ssbc x] (concat (map (fn [a b] (concat a (map #(conj % x) b))) (cons nil ssbc) ssbc) [[#{}]])) [[#{}]] s))
very neat! i'll try to keep that shift-and-map trick in mind.in the mean time, i came up with these variants on mine (http://paste.lisp.org/display/68832#1), but i think i stil prefer yours.
Yours is nice too. I tried to use iterate too but I hadn't been able to come up with a solution which doesn't use set or distinct to remove duplicates. Btw (clojure.set/difference a b) can also be written (apply disj a b).
Note: Only a member of this blog may post a comment.
very neat! i'll try to keep that shift-and-map trick in mind.
ReplyDeletein the mean time, i came up with these variants on mine (http://paste.lisp.org/display/68832#1), but i think i stil prefer yours.
Yours is nice too. I tried to use iterate too but I hadn't been able to come up with a solution which doesn't use set or distinct to remove duplicates. Btw (clojure.set/difference a b) can also be written (apply disj a b).
ReplyDelete