Skip to content

Instantly share code, notes, and snippets.

@pervognsen
Created March 17, 2010 09:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pervognsen/335063 to your computer and use it in GitHub Desktop.
Save pervognsen/335063 to your computer and use it in GitHub Desktop.
(defn unconj [coll]
(when (seq coll)
(let [x ((if (vector? coll) peek first) coll)]
[(cond
(list? coll) (rest coll)
(vector? coll) (subvec coll 0 (dec (count coll)))
(set? coll) (disj coll x)
(map? coll) (dissoc coll (x 0)))
x])))
;; forall coll, (seq coll) => (= (apply conj (unconj coll)) coll)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment