Skip to content

Instantly share code, notes, and snippets.

@tomjack

tomjack/core.clj Secret

Created August 22, 2011 12:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save tomjack/4a57022921afde8a6465 to your computer and use it in GitHub Desktop.
Save tomjack/4a57022921afde8a6465 to your computer and use it in GitHub Desktop.
(defn in-out-with-both [in out both]
((fn iob [[i & is :as iss]
[o & os :as oss]
[b & bs]]
(when b
(lazy-seq
(cond (= i b)
(cons [:in i] (iob is oss bs))
(= o b)
(cons [:out o] (iob iss os bs))
:else
(cons [:wtf b] (iob is os bs))))))
in out both))
(comment
cuhor.core> (in-out-with-both [:x :y :z] [:a :b :c] [:a :b :x :y :c :z])
([:out :a] [:out :b] [:in :x] [:in :y] [:out :c] [:in :z]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment