Created
February 17, 2011 14:34
-
-
Save fogus/831830 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
| (ns whee | |
| (:refer-clojure :exclude [conj])) | |
| (defprotocol Q | |
| (conj [q elem])) | |
| (extend-type clojure.lang.PersistentQueue | |
| Q | |
| (conj [this elem] | |
| (if (>= (count this) 3) | |
| this | |
| (clojure.core/conj this elem)))) | |
| (-> clojure.lang.PersistentQueue/EMPTY | |
| (conj :a) | |
| (conj :b) | |
| (conj :c) | |
| pop | |
| (conj :d) | |
| (conj :z) | |
| seq) | |
| ;=> (:b :c :d) | |
| (ns yay | |
| (:refer whee)) | |
| (-> clojure.lang.PersistentQueue/EMPTY | |
| (conj :a) | |
| (conj :b) | |
| (conj :c) | |
| pop | |
| (conj :d) | |
| (conj :z) | |
| seq) | |
| ;=> (:b :c :d) | |
| (-> clojure.lang.PersistentQueue/EMPTY | |
| (clojure.core/conj :a) | |
| (clojure.core/conj :b) | |
| (clojure.core/conj :c) | |
| pop | |
| (clojure.core/conj :d) | |
| (clojure.core/conj :z) | |
| seq) | |
| ;=> (:b :c :d :z) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment