diff options
author | Rich Hickey <richhickey@gmail.com> | 2009-07-18 12:17:11 -0400 |
---|---|---|
committer | Rich Hickey <richhickey@gmail.com> | 2009-07-18 12:17:11 -0400 |
commit | 936705a2dfbe574ac643d166bfb98a1a600b2ff0 (patch) | |
tree | eb12fca7cc4489ff5b39b1954408d304fb239151 | |
parent | 2363d0078392a4d88153dfb2393d0c01b53aff4a (diff) |
redef into with batch support
-rw-r--r-- | src/clj/clojure/core.clj | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/clj/clojure/core.clj b/src/clj/clojure/core.clj index 6e8ed1bb..ca000810 100644 --- a/src/clj/clojure/core.clj +++ b/src/clj/clojure/core.clj @@ -4360,3 +4360,18 @@ "Returns the value mapped to key, nil if key not present." [#^clojure.lang.IMutableAssociative coll key] (.valAt coll key)) + +;redef into with batch support +(defn into + "Returns a new coll consisting of to-coll with all of the items of + from-coll conjoined." + [to from] + (if (instance? clojure.lang.IEditableCollection to) + (#(loop [ret (mutable to) items (seq from)] + (if items + (recur (conj! ret (first items)) (next items)) + (immutable! ret)))) + (#(loop [ret to items (seq from)] + (if items + (recur (conj ret (first items)) (next items)) + ret))))) |