diff options
author | Rich Hickey <richhickey@gmail.com> | 2007-09-27 14:38:05 +0000 |
---|---|---|
committer | Rich Hickey <richhickey@gmail.com> | 2007-09-27 14:38:05 +0000 |
commit | f2839f790b521caaedf9b7b64991b0474757b4d2 (patch) | |
tree | 95535a16f090858a5d0eae79fbc60413ba20b6dc | |
parent | a255c8e8bc00b9adddd02c0e9714d862dacf8709 (diff) |
fixed order dependency on reverse/comp
-rw-r--r-- | src/boot.clj | 32 |
1 files changed, 20 insertions, 12 deletions
diff --git a/src/boot.clj b/src/boot.clj index d2e2e309..6a734a88 100644 --- a/src/boot.clj +++ b/src/boot.clj @@ -318,7 +318,24 @@ `(. clojure.lang.LockingTransaction (runInTransaction (fn [] ~@body)))) +;;;;;;;;;;;;;;;;;;; sequence fns ;;;;;;;;;;;;;;;;;;;;;;; + +(defn reduce + ([f coll] + (if (seq coll) + (thisfn f (rest coll) (first coll)) + (f))) + ([f coll val] + (if (seq coll) + (recur f (rest coll) (f val (first coll))) + val))) + +(defn reverse [coll] + (reduce conj coll nil)) + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; fn stuff ;;;;;;;;;;;;;;;; + + (defn comp [& fs] (let [fs (reverse fs)] (fn [& args] @@ -339,6 +356,8 @@ ;;;;;;;;;;;;;;;;;;; sequence fns ;;;;;;;;;;;;;;;;;;;;;;; + + (defn every [pred coll] (if (seq coll) (and (pred (first coll)) @@ -364,16 +383,6 @@ (defn mapcat [f & colls] (apply concat (apply map f colls))) - -(defn reduce - ([f coll] - (if (seq coll) - (thisfn f (rest coll) (first coll)) - (f))) - ([f coll val] - (if (seq coll) - (recur f (rest coll) (f val (first coll))) - val))) (defn filter [pred coll] (when (seq coll) @@ -399,8 +408,7 @@ (recur pred (rest coll)) coll)) -(defn reverse [coll] - (reduce conj coll nil)) + (defn cycle-rep [xs ys] (if xs |