Created
March 17, 2010 09:22
-
-
Save pervognsen/335063 to your computer and use it in GitHub Desktop.
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 characters
(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