diff options
author | Rich Hickey <richhickey@gmail.com> | 2009-02-14 19:05:50 +0000 |
---|---|---|
committer | Rich Hickey <richhickey@gmail.com> | 2009-02-14 19:05:50 +0000 |
commit | 20331a1681ebc7ba714d0e55563cb51d143c1afc (patch) | |
tree | e6eb1e8ddcb65237ec78bdd636a9f043d084b0d7 | |
parent | 8c59f860762c7b202f0926be401a19e031bfa110 (diff) |
[lazy] renamed rest to next, renamed more to rest
39 files changed, 729 insertions, 737 deletions
diff --git a/src/clj/clojure/core.clj b/src/clj/clojure/core.clj index 3cdeb73c..1c164fe3 100644 --- a/src/clj/clojure/core.clj +++ b/src/clj/clojure/core.clj @@ -49,13 +49,13 @@ #^{:arglists '([coll]) :doc "Returns a seq of the items after the first. Calls seq on its argument. If there are no more items, returns nil."} - rest (fn rest [x] (. clojure.lang.RT (rest x)))) + next (fn next [x] (. clojure.lang.RT (next x)))) (def #^{:arglists '([coll]) :doc "Returns a seqable collection of the items after the first. May return nil. Calls seq on its argument."} - more (fn more [x] (. clojure.lang.RT (more x)))) + rest (fn rest [x] (. clojure.lang.RT (more x)))) (def #^{:arglists '([coll x] [coll x & xs]) @@ -66,13 +66,13 @@ ([coll x] (. clojure.lang.RT (conj coll x))) ([coll x & xs] (if xs - (recur (conj coll x) (first xs) (rest xs)) + (recur (conj coll x) (first xs) (next xs)) (conj coll x))))) (def - #^{:doc "Same as (first (rest x))" + #^{:doc "Same as (first (next x))" :arglists '([x])} - second (fn second [x] (first (rest x)))) + second (fn second [x] (first (next x)))) (def #^{:doc "Same as (first (first x))" @@ -80,19 +80,19 @@ ffirst (fn ffirst [x] (first (first x)))) (def - #^{:doc "Same as (rest (first x))" + #^{:doc "Same as (next (first x))" :arglists '([x])} - rfirst (fn rfirst [x] (rest (first x)))) + nfirst (fn nfirst [x] (next (first x)))) (def - #^{:doc "Same as (first (rest x))" + #^{:doc "Same as (first (next x))" :arglists '([x])} - frest (fn frest [x] (first (rest x)))) + fnext (fn fnext [x] (first (next x)))) (def - #^{:doc "Same as (rest (rest x))" + #^{:doc "Same as (next (next x))" :arglists '([x])} - rrest (fn rrest [x] (rest (rest x)))) + nnext (fn nnext [x] (next (next x)))) (def #^{:arglists '([coll]) @@ -141,7 +141,7 @@ (if (sequence? (first fdecl)) (loop [ret [] fdecl fdecl] (if fdecl - (recur (conj ret (first (first fdecl))) (rest fdecl)) + (recur (conj ret (first (first fdecl))) (next fdecl)) (seq ret))) (list (first fdecl))))) @@ -157,7 +157,7 @@ ([map key val & kvs] (let [ret (assoc map key val)] (if kvs - (recur ret (first kvs) (second kvs) (rrest kvs)) + (recur ret (first kvs) (second kvs) (nnext kvs)) ret))))) ;;;;;;;;;;;;;;;;; metadata ;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -179,8 +179,8 @@ #^{:arglists '([coll]) :doc "Return the last item in coll, in linear time"} last (fn last [s] - (if (rest s) - (recur (rest s)) + (if (next s) + (recur (next s)) (first s)))) (def @@ -188,8 +188,8 @@ :doc "Return a sequence of all but the last item in coll, in linear time"} butlast (fn butlast [s] (loop [ret [] s s] - (if (rest s) - (recur (conj ret (first s)) (rest s)) + (if (next s) + (recur (conj ret (first s)) (next s)) (seq ret))))) (def @@ -204,13 +204,13 @@ {:doc (first fdecl)} {}) fdecl (if (string? (first fdecl)) - (rest fdecl) + (next fdecl) fdecl) m (if (map? (first fdecl)) (conj m (first fdecl)) m) fdecl (if (map? (first fdecl)) - (rest fdecl) + (next fdecl) fdecl) fdecl (if (vector? (first fdecl)) (list fdecl) @@ -303,7 +303,7 @@ (defmacro if [tst & etc] (if* (assert-if-lazy-seq?) (let [tstsym 'G__0_0] - (list 'let [tstsym tst] + (list 'clojure.core/let [tstsym tst] (list 'if* (list 'clojure.core/instance? clojure.lang.LazySeq tstsym) (list 'throw (list 'new Exception "LazySeq used in 'if'")) (cons 'if* (cons tstsym etc))))) @@ -350,7 +350,7 @@ ([x & ys] ((fn [#^StringBuilder sb more] (if more - (recur (. sb (append (str (first more)))) (rest more)) + (recur (. sb (append (str (first more)))) (next more)) (str sb))) (new StringBuilder #^String (str x)) ys))) @@ -389,19 +389,19 @@ [& clauses] (when clauses (list 'if (first clauses) - (if (rest clauses) + (if (next clauses) (second clauses) (throw (IllegalArgumentException. "cond requires an even number of forms"))) - (cons 'clojure.core/cond (rest (rest clauses)))))) + (cons 'clojure.core/cond (next (next clauses)))))) (defn spread {:private true} [arglist] (cond (nil? arglist) nil - (nil? (rest arglist)) (seq (first arglist)) - :else (cons (first arglist) (spread (rest arglist))))) + (nil? (next arglist)) (seq (first arglist)) + :else (cons (first arglist) (spread (next arglist))))) (defn apply "Applies fn f to the argument list formed by prepending args to argseq." @@ -437,16 +437,16 @@ (lazy-seq (let [s (seq x)] (if s - (cons (first s) (concat (more s) y)) + (cons (first s) (concat (rest s) y)) y)))) ([x y & zs] (let [cat (fn cat [xys zs] (lazy-seq (let [xys (seq xys)] (if xys - (cons (first xys) (cat (more xys) zs)) + (cons (first xys) (cat (rest xys) zs)) (when zs - (cat (first zs) (rest zs)))))))] + (cat (first zs) (next zs)))))))] (cat (concat x y) zs)))) ;;;;;;;;;;;;;;;;at this point all the support for syntax-quote exists;;;;;;;;;;;;;;;;;;;;;; @@ -488,8 +488,8 @@ ([x y] (clojure.lang.Util/equiv x y)) ([x y & more] (if (= x y) - (if (rest more) - (recur y (first more) (rest more)) + (if (next more) + (recur y (first more) (next more)) (= y (first more))) false))) @@ -519,9 +519,9 @@ the value of the last expr. (and) returns true." ([] true) ([x] x) - ([x & rest] + ([x & next] `(let [and# ~x] - (if and# (and ~@rest) and#)))) + (if and# (and ~@next) and#)))) (defmacro or "Evaluates exprs one at a time, from left to right. If a form @@ -530,9 +530,9 @@ value of the last expression. (or) returns nil." ([] nil) ([x] x) - ([x & rest] + ([x & next] `(let [or# ~x] - (if or# or# (or ~@rest))))) + (if or# or# (or ~@next))))) ;;;;;;;;;;;;;;;;;;; sequence fns ;;;;;;;;;;;;;;;;;;;;;;; (defn reduce @@ -550,7 +550,7 @@ (if s (if (instance? clojure.lang.IReduce s) (. #^clojure.lang.IReduce s (reduce f)) - (reduce f (first s) (rest s))) + (reduce f (first s) (next s))) (f)))) ([f val coll] (let [s (seq coll)] @@ -558,7 +558,7 @@ (. #^clojure.lang.IReduce s (reduce f val)) ((fn [f val s] (if s - (recur f (f val (first s)) (rest s)) + (recur f (f val (first s)) (next s)) val)) f val s))))) @@ -617,8 +617,8 @@ ([x y] (. clojure.lang.Numbers (lt x y))) ([x y & more] (if (< x y) - (if (rest more) - (recur y (first more) (rest more)) + (if (next more) + (recur y (first more) (next more)) (< y (first more))) false))) @@ -631,8 +631,8 @@ ([x y] (. clojure.lang.Numbers (lte x y))) ([x y & more] (if (<= x y) - (if (rest more) - (recur y (first more) (rest more)) + (if (next more) + (recur y (first more) (next more)) (<= y (first more))) false))) @@ -645,8 +645,8 @@ ([x y] (. clojure.lang.Numbers (gt x y))) ([x y & more] (if (> x y) - (if (rest more) - (recur y (first more) (rest more)) + (if (next more) + (recur y (first more) (next more)) (> y (first more))) false))) @@ -659,8 +659,8 @@ ([x y] (. clojure.lang.Numbers (gte x y))) ([x y & more] (if (>= x y) - (if (rest more) - (recur y (first more) (rest more)) + (if (next more) + (recur y (first more) (next more)) (>= y (first more))) false))) @@ -672,8 +672,8 @@ ([x y] (. clojure.lang.Numbers (equiv x y))) ([x y & more] (if (== x y) - (if (rest more) - (recur y (first more) (rest more)) + (if (next more) + (recur y (first more) (next more)) (== y (first more))) false))) @@ -883,7 +883,7 @@ "For a list or queue, returns a new list/queue without the first item, for a vector, returns a new vector without the last item. If the collection is empty, throws an exception. Note - not the same - as rest/butlast." + as next/butlast." [coll] (. clojure.lang.RT (pop coll))) (defn nth @@ -920,7 +920,7 @@ ([map key & ks] (let [ret (dissoc map key)] (if ks - (recur ret (first ks) (rest ks)) + (recur ret (first ks) (next ks)) ret)))) (defn disj @@ -932,7 +932,7 @@ ([set key & ks] (let [ret (disj set key)] (if ks - (recur ret (first ks) (rest ks)) + (recur ret (first ks) (next ks)) ret)))) (defn find @@ -949,7 +949,7 @@ (if entry (conj ret entry) ret) - (rest keys))) + (next keys))) ret))) (defn keys @@ -1022,7 +1022,7 @@ list already. If there are more forms, inserts the first form as the second item in second form, etc." ([x form] (if (sequence? form) - `(~(first form) ~x ~@(rest form)) + `(~(first form) ~x ~@(next form)) (list form x))) ([x form & more] `(-> (-> ~x ~form) ~@more))) @@ -1039,16 +1039,16 @@ (first options) nil) options (if (string? (first options)) - (rest options) + (next options) options) m (if (map? (first options)) (first options) {}) options (if (map? (first options)) - (rest options) + (next options) options) dispatch-fn (first options) - options (rest options) + options (next options) m (assoc m :tag 'clojure.lang.MultiFn) m (if docstring (assoc m :doc docstring) @@ -1092,7 +1092,7 @@ `(do (when-not ~(first pairs) (throw (IllegalArgumentException. ~(str fnname " requires " (second pairs))))) - ~(let [more (rrest pairs)] + ~(let [more (nnext pairs)] (when more (list* `assert-args fnname more))))) @@ -1141,7 +1141,7 @@ (loop [ret [] vvs (seq var-vals)] (if vvs (recur (conj (conj ret `(var ~(first vvs))) (second vvs)) - (rest (rest vvs))) + (next (next vvs))) (seq ret))))] `(do (. clojure.lang.Var (pushThreadBindings (hash-map ~@(var-ize bindings)))) @@ -1392,7 +1392,7 @@ exception message." [& body] (let [message (when (string? (first body)) (first body)) - body (if message (rest body) body)] + body (if message (next body) body)] `(if (clojure.lang.LockingTransaction/isRunning) (throw (new IllegalStateException ~(or message "I/O in transaction"))) (do ~@body)))) @@ -1408,9 +1408,9 @@ [& fs] (let [fs (reverse fs)] (fn [& args] - (loop [ret (apply (first fs) args) fs (rest fs)] + (loop [ret (apply (first fs) args) fs (next fs)] (if fs - (recur ((first fs) ret) (rest fs)) + (recur ((first fs) ret) (next fs)) ret))))) (defn partial @@ -1435,7 +1435,7 @@ [pred coll] (if (seq coll) (and (pred (first coll)) - (recur pred (rest coll))) + (recur pred (next coll))) true)) (def @@ -1452,7 +1452,7 @@ (some #{:fred} coll)" [pred coll] (when (seq coll) - (or (pred (first coll)) (recur pred (rest coll))))) + (or (pred (first coll)) (recur pred (next coll))))) (def #^{:tag Boolean @@ -1470,25 +1470,25 @@ ([f coll] (lazy-seq (when-let [s (seq coll)] - (cons (f (first s)) (map f (more s)))))) + (cons (f (first s)) (map f (rest s)))))) ([f c1 c2] (lazy-seq (let [s1 (seq c1) s2 (seq c2)] (when (and s1 s2) (cons (f (first s1) (first s2)) - (map f (more s1) (more s2))))))) + (map f (rest s1) (rest s2))))))) ([f c1 c2 c3] (lazy-seq (let [s1 (seq c1) s2 (seq c2) s3 (seq c3)] (when (and s1 s2 s3) (cons (f (first s1) (first s2) (first s3)) - (map f (more s1) (more s2) (more s3))))))) + (map f (rest s1) (rest s2) (rest s3))))))) ([f c1 c2 c3 & colls] (let [step (fn step [cs] (lazy-seq (let [ss (map seq cs)] (when (every? identity ss) - (cons (map first ss) (step (map more ss)))))))] + (cons (map first ss) (step (map rest ss)))))))] (map #(apply f %) (step (conj colls c3 c2 c1)))))) (defn mapcat @@ -1504,8 +1504,8 @@ (let [step (fn [p c] (when-let [s (seq c)] (if (p (first s)) - (clojure.lang.Cons. (first s) (filter p (more s))) - (recur p (more s)))))] + (clojure.lang.Cons. (first s) (filter p (rest s))) + (recur p (rest s)))))] (lazy-seq (step pred coll)))) @@ -1522,7 +1522,7 @@ (lazy-seq (when (pos? n) (when-let [s (seq coll)] - (cons (first s) (take (dec n) (more s))))))) + (cons (first s) (take (dec n) (rest s))))))) (defn take-while "Returns a lazy sequence of successive items from coll while @@ -1531,7 +1531,7 @@ (lazy-seq (when-let [s (seq coll)] (when (pred (first s)) - (cons (first s) (take-while pred (more s))))))) + (cons (first s) (take-while pred (rest s))))))) (defn drop "Returns a lazy sequence of all but the first n items in coll." @@ -1539,7 +1539,7 @@ (let [step (fn [n coll] (let [s (seq coll)] (if (and (pos? n) s) - (recur (dec n) (more s)) + (recur (dec n) (rest s)) s)))] (lazy-seq (step n coll)))) @@ -1555,7 +1555,7 @@ (let [step (fn [pred coll] (let [s (seq coll)] (if (and s (pred (first s))) - (recur pred (more s)) + (recur pred (rest s)) s)))] (lazy-seq (step pred coll)))) @@ -1634,8 +1634,8 @@ vs (seq vals)] (if (and ks vs) (recur (assoc map (first ks) (first vs)) - (rest ks) - (rest vs)) + (next ks) + (next vs)) map))) (defn line-seq @@ -1716,27 +1716,27 @@ ~(if more-groups (apply emit more-groups) `(do ~@body))) - (recur (rest sq#)))))))] + (recur (next sq#)))))))] (apply emit groups))) (defn dorun "When lazy sequences are produced via functions that have side effects, any effects other than those needed to produce the first element in the seq do not occur until the seq is consumed. dorun can - be used to force any effects. Walks through the successive rests of + be used to force any effects. Walks through the successive nexts of the seq, does not retain the head and returns nil." ([coll] (when (and (seq coll) (or (first coll) true)) - (recur (rest coll)))) + (recur (next coll)))) ([n coll] (when (and (seq coll) (pos? n) (or (first coll) true)) - (recur (dec n) (rest coll))))) + (recur (dec n) (next coll))))) (defn doall "When lazy sequences are produced via functions that have side effects, any effects other than those needed to produce the first element in the seq do not occur until the seq is consumed. doall can - be used to force any effects. Walks through the successive rests of + be used to force any effects. Walks through the successive nexts of the seq, retains the head and returns it, thus causing the entire seq to reside in memory at one time." ([coll] @@ -1812,7 +1812,7 @@ c (symbol (.substring n (inc dot)))] (. ns (importClass c (. clojure.lang.RT (classForName (name spec)))))) (let [pkg (first spec) - classes (rest spec)] + classes (next spec)] (doseq [c classes] (. ns (importClass c (. clojure.lang.RT (classForName (str pkg "." c))))))))))) @@ -1834,7 +1834,7 @@ [to from] (let [ret to items (seq from)] (if items - (recur (conj ret (first items)) (rest items)) + (recur (conj ret (first items)) (next items)) ret))) (defn #^{:private true} @@ -2081,7 +2081,7 @@ `(let [~gx ~x] ~@(map (fn [f] (if (sequence? f) - `(~(first f) ~gx ~@(rest f)) + `(~(first f) ~gx ~@(next f)) `(~f ~gx))) forms) ~gx))) @@ -2209,7 +2209,7 @@ (loop [i 0 xs (seq coll)] (when xs (aset ret i (to-array (first xs))) - (recur (inc i) (rest xs)))) + (recur (inc i) (next xs)))) ret)) (defn macroexpand-1 @@ -2300,8 +2300,8 @@ (loop [ret {} es (seq amap)] (if es (if (pred (keyfn (first es))) - (recur (assoc ret (key (first es)) (val (first es))) (rest es)) - (recur ret (rest es))) + (recur (assoc ret (key (first es)) (val (first es))) (next es)) + (recur ret (next es))) ret))) (defn find-ns @@ -2485,12 +2485,12 @@ ([] (. clojure.lang.PersistentArrayMap EMPTY)) ([& keyvals] (new clojure.lang.PersistentArrayMap (to-array keyvals)))) -(defn nthrest - "Returns the nth rest of coll, (seq coll) when n is 0." +(defn nthnext + "Returns the nth next of coll, (seq coll) when n is 0." [coll n] (loop [n n xs (seq coll)] (if (and xs (pos? n)) - (recur (dec n) (rest xs)) + (recur (dec n) (next xs)) xs))) @@ -2508,16 +2508,16 @@ (if (seq bs) (let [firstb (first bs)] (cond - (= firstb '&) (recur (pb ret (second bs) (list `nthrest gvec n)) + (= firstb '&) (recur (pb ret (second bs) (list `nthnext gvec n)) n - (rrest bs) + (nnext bs) true) (= firstb :as) (pb ret (second bs) gvec) :else (if seen-rest? (throw (new Exception "Unsupported binding form, only :as can follow & parameter")) (recur (pb ret firstb (list `nth gvec n nil)) (inc n) - (rest bs) + (next bs) seen-rest?)))) ret)))) pmap @@ -2539,7 +2539,7 @@ (recur (pb ret bb (if has-default (list `get gmap bk (defaults bb)) (list `get gmap bk))) - (rest bes))) + (next bes))) ret))))] (cond (symbol? b) (-> bvec (conj b) (conj v)) @@ -2566,15 +2566,15 @@ "(fn name? [params* ] exprs*) (fn name? ([params* ] exprs*)+) - params => positional-params* , or positional-params* & rest-param + params => positional-params* , or positional-params* & next-param positional-param => binding-form - rest-param => binding-form + next-param => binding-form name => symbol Defines a function" [& sigs] (let [name (if (symbol? (first sigs)) (first sigs) nil) - sigs (if name (rest sigs) sigs) + sigs (if name (next sigs) sigs) sigs (if (vector? (first sigs)) (list sigs) sigs) psig (fn [sig] (let [[params & body] sig] @@ -2585,9 +2585,9 @@ lets []] (if params (if (symbol? (first params)) - (recur (rest params) (conj new-params (first params)) lets) + (recur (next params) (conj new-params (first params)) lets) (let [gparam (gensym "p__")] - (recur (rest params) (conj new-params gparam) + (recur (next params) (conj new-params gparam) (-> lets (conj (first params)) (conj gparam))))) `(~new-params (let ~lets @@ -2677,10 +2677,10 @@ `(let [iterys# ~(emit more-groups) fs# (seq (iterys# ~next-seq))] (if fs# - (concat fs# (~giter (more ~gxs))) - (recur (more ~gxs)))) - `(cons ~expr (~giter (more ~gxs)))) - (recur (more ~gxs)))))))))))] + (concat fs# (~giter (rest ~gxs))) + (recur (rest ~gxs)))) + `(cons ~expr (~giter (rest ~gxs)))) + (recur (rest ~gxs)))))))))))] `(let [iter# ~(emit (to-groups seq-exprs))] (iter# ~(second seq-exprs)))))) @@ -2967,8 +2967,8 @@ ((fn [[f :as xs] seen] (when-let [s (seq xs)] (if (seen f) - (recur (more s) seen) - (cons f (step (more s) (conj seen f)))))) + (recur (rest s) seen) + (cons f (step (rest s) (conj seen f)))))) xs seen)))] (step coll #{}))) @@ -3006,7 +3006,7 @@ HALF_EVEN, UP, DOWN and UNNECESSARY; it defaults to HALF_UP." [precision & exprs] (let [[body rm] (if (= (first exprs) :rounding) - [(rest (rest exprs)) + [(next (next exprs)) `((. java.math.RoundingMode ~(second exprs)))] [exprs nil])] `(binding [*math-context* (java.math.MathContext. ~precision ~@rm)] @@ -3026,12 +3026,12 @@ (let [include (bound-fn sc test key)] (if (#{> >=} test) (when-let [[e :as s] (. sc seqFrom key true)] - (if (include e) s (rest s))) + (if (include e) s (next s))) (take-while include (. sc seq true))))) ([#^clojure.lang.Sorted sc start-test start-key end-test end-key] (when-let [[e :as s] (. sc seqFrom start-key true)] (take-while (bound-fn sc end-test end-key) - (if ((bound-fn sc start-test start-key) e) s (rest s)))))) + (if ((bound-fn sc start-test start-key) e) s (next s)))))) (defn rsubseq "sc must be a sorted collection, test(s) one of <, <=, > or @@ -3041,12 +3041,12 @@ (let [include (bound-fn sc test key)] (if (#{< <=} test) (when-let [[e :as s] (. sc seqFrom key false)] - (if (include e) s (rest s))) + (if (include e) s (next s))) (take-while include (. sc seq false))))) ([#^clojure.lang.Sorted sc start-test start-key end-test end-key] (when-let [[e :as s] (. sc seqFrom end-key false)] (take-while (bound-fn sc start-test start-key) - (if ((bound-fn sc end-test end-key) e) s (rest s)))))) + (if ((bound-fn sc end-test end-key) e) s (next s)))))) (defn repeatedly "Takes a function of no args, presumably with side effects, and returns an infinite @@ -3407,7 +3407,7 @@ `(~(symbol "clojure.core" (clojure.core/name kname)) ~@(map #(list 'quote %) args))) docstring (when (string? (first references)) (first references)) - references (if docstring (rest references) references) + references (if docstring (next references) references) name (if docstring (with-meta name (assoc (meta name) :doc docstring)) @@ -3415,7 +3415,7 @@ gen-class-clause (first (filter #(= :gen-class (first %)) references)) gen-class-call (when gen-class-clause - (list* `gen-class :name (.replace (str name) \- \_) :impl-ns name :main true (rest gen-class-clause))) + (list* `gen-class :name (.replace (str name) \- \_) :impl-ns name :main true (next gen-class-clause))) references (remove #(= :gen-class (first %)) references)] `(do (clojure.core/in-ns '~name) @@ -3782,7 +3782,7 @@ (lazy-seq (let [ss (map seq cs)] (when (every? identity ss) - (cons (map first ss) (step (map rest ss)))))))] + (cons (map first ss) (step (map next ss)))))))] (pmap #(apply f %) (step (cons coll colls)))))) (def diff --git a/src/clj/clojure/core_proxy.clj b/src/clj/clojure/core_proxy.clj index edbc78fe..d1176781 100644 --- a/src/clj/clojure/core_proxy.clj +++ b/src/clj/clojure/core_proxy.clj @@ -165,8 +165,8 @@ (. Modifier (isStatic mods)) (. Modifier (isFinal mods)) (= "finalize" (.getName meth))) - (recur mm (conj considered mk) (rest meths)) - (recur (assoc mm mk meth) (conj considered mk) (rest meths)))) + (recur mm (conj considered mk) (next meths)) + (recur (assoc mm mk meth) (conj considered mk) (next meths)))) [mm considered]))] (recur mm considered (. c (getSuperclass)))) [mm considered]))] @@ -199,7 +199,7 @@ (defn- get-super-and-interfaces [bases] (if (. #^Class (first bases) (isInterface)) [Object bases] - [(first bases) (rest bases)])) + [(first bases) (next bases)])) (defn get-proxy-class "Takes an optional single class followed by zero or more @@ -290,7 +290,7 @@ meths (map (fn [[params & body]] (cons (apply vector 'this params) body)) meths)] - (recur (assoc fmap (name sym) (cons `fn meths)) (rest fs))) + (recur (assoc fmap (name sym) (cons `fn meths)) (next fs))) fmap))) p#))) @@ -341,7 +341,7 @@ (lazy-seq (when pseq (cons (new clojure.lang.MapEntry (first pseq) (v (first pseq))) - (thisfn (more pseq))))) (keys pmap))))))) + (thisfn (rest pseq))))) (keys pmap))))))) diff --git a/src/clj/clojure/genclass.clj b/src/clj/clojure/genclass.clj index f7076e70..b7bb74f8 100644 --- a/src/clj/clojure/genclass.clj +++ b/src/clj/clojure/genclass.clj @@ -37,8 +37,8 @@ (. Modifier (isStatic mods)) (. Modifier (isFinal mods)) (= "finalize" (.getName meth))) - (recur mm (conj considered mk) (rest meths)) - (recur (assoc mm mk meth) (conj considered mk) (rest meths)))) + (recur mm (conj considered mk) (next meths)) + (recur (assoc mm mk meth) (conj considered mk) (next meths)))) [mm considered]))] (recur mm considered (. c (getSuperclass)))) mm))) @@ -130,7 +130,7 @@ all-sigs (distinct (concat (map #(let[[m p] (key %)] {m [p]}) (mapcat non-private-methods supers)) (map (fn [[m p]] {(str m) [p]}) methods))) sigs-by-name (apply merge-with concat {} all-sigs) - overloads (into {} (filter (fn [[m s]] (rest s)) sigs-by-name)) + overloads (into {} (filter (fn [[m s]] (next s)) sigs-by-name)) var-fields (concat (when init [init-name]) (when main [main-name]) ;(when exposes-methods (map str (vals exposes-methods))) diff --git a/src/clj/clojure/zip.clj b/src/clj/clojure/zip.clj index 1333ae1e..be3bef76 100644 --- a/src/clj/clojure/zip.clj +++ b/src/clj/clojure/zip.clj @@ -10,7 +10,7 @@ ;see Huet (ns clojure.zip - (:refer-clojure :exclude (replace remove))) + (:refer-clojure :exclude (replace remove next))) (defn zipper "Creates a new zipper structure. @@ -89,12 +89,12 @@ nil if no children" [loc] (let [[node path] loc - [c & crest :as cs] (children loc)] + [c & cnext :as cs] (children loc)] (when cs (with-meta [c {:l [] :pnodes (if path (conj (:pnodes path) node) [node]) :ppath path - :r crest}] ^loc)))) + :r cnext}] ^loc)))) (defn up "Returns the loc of the parent of the node at this loc, or nil if at @@ -123,9 +123,9 @@ (defn right "Returns the loc of the right sibling of the node at this loc, or nil" [loc] - (let [[node {l :l [r & rrest :as rs] :r :as path}] loc] + (let [[node {l :l [r & rnext :as rs] :r :as path}] loc] (when (and path rs) - (with-meta [r (assoc path :l (conj l node) :r rrest)] ^loc)))) + (with-meta [r (assoc path :l (conj l node) :r rnext)] ^loc)))) (defn left "Returns the loc of the left sibling of the node at this loc, or nil" diff --git a/src/jvm/clojure/lang/AFn.java b/src/jvm/clojure/lang/AFn.java index bf406969..e2646ade 100644 --- a/src/jvm/clojure/lang/AFn.java +++ b/src/jvm/clojure/lang/AFn.java @@ -12,7 +12,6 @@ package clojure.lang; -import java.util.Comparator; import java.io.Serializable; public abstract class AFn extends Obj implements IFn, Serializable{ @@ -174,273 +173,273 @@ static public Object applyToHelper(IFn ifn, ISeq arglist) throws Exception{ return ifn.invoke(arglist.first()); case 2: return ifn.invoke(arglist.first() - , (arglist = arglist.rest()).first() + , (arglist = arglist.next()).first() ); case 3: return ifn.invoke(arglist.first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() ); case 4: return ifn.invoke(arglist.first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() ); case 5: return ifn.invoke(arglist.first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() ); case 6: return ifn.invoke(arglist.first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() ); case 7: return ifn.invoke(arglist.first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() ); case 8: return ifn.invoke(arglist.first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() ); case 9: return ifn.invoke(arglist.first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() ); case 10: return ifn.invoke(arglist.first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() ); case 11: return ifn.invoke(arglist.first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() ); case 12: return ifn.invoke(arglist.first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() ); case 13: return ifn.invoke(arglist.first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() ); case 14: return ifn.invoke(arglist.first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() ); case 15: return ifn.invoke(arglist.first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() ); case 16: return ifn.invoke(arglist.first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() ); case 17: return ifn.invoke(arglist.first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() ); case 18: return ifn.invoke(arglist.first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() ); case 19: return ifn.invoke(arglist.first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() ); case 20: return ifn.invoke(arglist.first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() ); default: return ifn.invoke(arglist.first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , RT.seqToArray(arglist.rest())); + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , RT.seqToArray(arglist.next())); } } diff --git a/src/jvm/clojure/lang/APersistentMap.java b/src/jvm/clojure/lang/APersistentMap.java index 4d8bc8f7..743f4480 100644 --- a/src/jvm/clojure/lang/APersistentMap.java +++ b/src/jvm/clojure/lang/APersistentMap.java @@ -44,7 +44,7 @@ public IPersistentCollection cons(Object o){ }
IPersistentMap ret = this;
- for(ISeq es = RT.seq(o); es != null; es = es.rest())
+ for(ISeq es = RT.seq(o); es != null; es = es.next())
{
Map.Entry e = (Map.Entry) es.first();
ret = ret.assoc(e.getKey(), e.getValue());
@@ -60,7 +60,7 @@ public boolean equals(Object obj){ if(m.size() != size() || m.hashCode() != hashCode())
return false;
- for(ISeq s = seq(); s != null; s = s.rest())
+ for(ISeq s = seq(); s != null; s = s.next())
{
Map.Entry e = (Map.Entry) s.first();
boolean found = m.containsKey(e.getKey());
@@ -80,7 +80,7 @@ public boolean equiv(Object obj){ if(m.size() != size())
return false;
- for(ISeq s = seq(); s != null; s = s.rest())
+ for(ISeq s = seq(); s != null; s = s.next())
{
Map.Entry e = (Map.Entry) s.first();
boolean found = m.containsKey(e.getKey());
@@ -96,7 +96,7 @@ public int hashCode(){ {
//int hash = count();
int hash = 0;
- for(ISeq s = seq(); s != null; s = s.rest())
+ for(ISeq s = seq(); s != null; s = s.next())
{
Map.Entry e = (Map.Entry) s.first();
hash += (e.getKey() == null ? 0 : e.getKey().hashCode()) ^
@@ -130,8 +130,8 @@ static public class KeySeq extends ASeq{ return ((Map.Entry) seq.first()).getKey();
}
- public ISeq rest(){
- return create(seq.rest());
+ public ISeq next(){
+ return create(seq.next());
}
public KeySeq withMeta(IPersistentMap meta){
@@ -161,8 +161,8 @@ static public class ValSeq extends ASeq{ return ((Map.Entry) seq.first()).getValue();
}
- public ISeq rest(){
- return create(seq.rest());
+ public ISeq next(){
+ return create(seq.next());
}
public ValSeq withMeta(IPersistentMap meta){
diff --git a/src/jvm/clojure/lang/APersistentSet.java b/src/jvm/clojure/lang/APersistentSet.java index 36063276..d6e815e9 100644 --- a/src/jvm/clojure/lang/APersistentSet.java +++ b/src/jvm/clojure/lang/APersistentSet.java @@ -80,7 +80,7 @@ public int hashCode(){ { //int hash = count(); int hash = 0; - for(ISeq s = seq(); s != null; s = s.rest()) + for(ISeq s = seq(); s != null; s = s.next()) { Object e = s.first(); // hash = Util.hashCombine(hash, Util.hash(e)); @@ -132,7 +132,7 @@ public Object[] toArray(Object[] a){ if(a.length >= count()) { ISeq s = seq(); - for(int i = 0; s != null; ++i, s = s.rest()) + for(int i = 0; s != null; ++i, s = s.next()) { a[i] = s.first(); } diff --git a/src/jvm/clojure/lang/APersistentVector.java b/src/jvm/clojure/lang/APersistentVector.java index 4cb753a8..a8017688 100644 --- a/src/jvm/clojure/lang/APersistentVector.java +++ b/src/jvm/clojure/lang/APersistentVector.java @@ -73,7 +73,7 @@ static boolean doEquals(IPersistentVector v, Object obj){ if(!(obj instanceof Sequential)) return false; ISeq ms = RT.seq(obj); - for(int i = 0; i < v.count(); i++, ms = ms.rest()) + for(int i = 0; i < v.count(); i++, ms = ms.next()) { if(ms == null || !Util.equals(v.nth(i), ms.first())) return false; @@ -116,7 +116,7 @@ static boolean doEquiv(IPersistentVector v, Object obj){ if(!(obj instanceof Sequential)) return false; ISeq ms = RT.seq(obj); - for(int i = 0; i < v.count(); i++, ms = ms.rest()) + for(int i = 0; i < v.count(); i++, ms = ms.next()) { if(ms == null || !Util.equiv(v.nth(i), ms.first())) return false; @@ -357,7 +357,7 @@ public Object[] toArray(Object[] a){ if(a.length >= count()) { ISeq s = seq(); - for(int i = 0; s != null; ++i, s = s.rest()) + for(int i = 0; s != null; ++i, s = s.next()) { a[i] = s.first(); } @@ -378,7 +378,7 @@ public boolean isEmpty(){ } public boolean contains(Object o){ - for(ISeq s = seq(); s != null; s = s.rest()) + for(ISeq s = seq(); s != null; s = s.next()) { if(Util.equiv(s.first(), o)) return true; @@ -438,7 +438,7 @@ public IStream stream() throws Exception { return v.nth(i); } - public ISeq rest(){ + public ISeq next(){ if(i + 1 < v.count()) return new APersistentVector.Seq(v, i + 1); return null; @@ -469,7 +469,7 @@ public IStream stream() throws Exception { ret = f.invoke(ret, v.nth(x)); return ret; } -} + } static class RSeq extends ASeq implements IndexedSeq{ final IPersistentVector v; @@ -490,7 +490,7 @@ static class RSeq extends ASeq implements IndexedSeq{ return v.nth(i); } - public ISeq rest(){ + public ISeq next(){ if(i > 0) return new APersistentVector.RSeq(v, i - 1); return null; diff --git a/src/jvm/clojure/lang/ARef.java b/src/jvm/clojure/lang/ARef.java index c165db9f..dd60752f 100644 --- a/src/jvm/clojure/lang/ARef.java +++ b/src/jvm/clojure/lang/ARef.java @@ -102,7 +102,7 @@ public abstract class ARef extends AReference implements IRef { if (ws != null) { ISeq args = new Cons(this, null); - for (ISeq s = RT.seq(ws); s != null; s = s.rest()) + for (ISeq s = RT.seq(ws); s != null; s = s.next()) { Map.Entry e = (Map.Entry) s.first(); Object[] a = (Object[]) e.getValue(); diff --git a/src/jvm/clojure/lang/ASeq.java b/src/jvm/clojure/lang/ASeq.java index 31faa021..fdd41c78 100644 --- a/src/jvm/clojure/lang/ASeq.java +++ b/src/jvm/clojure/lang/ASeq.java @@ -36,7 +36,7 @@ public boolean equiv(Object obj){ if(!(obj instanceof Sequential || obj instanceof List))
return false;
ISeq ms = RT.seq(obj);
- for(ISeq s = seq(); s != null; s = s.rest(), ms = ms.rest())
+ for(ISeq s = seq(); s != null; s = s.next(), ms = ms.next())
{
if(ms == null || !Util.equiv(s.first(), ms.first()))
return false;
@@ -50,7 +50,7 @@ public boolean equals(Object obj){ if(!(obj instanceof Sequential || obj instanceof List))
return false;
ISeq ms = RT.seq(obj);
- for(ISeq s = seq(); s != null; s = s.rest(), ms = ms.rest())
+ for(ISeq s = seq(); s != null; s = s.next(), ms = ms.next())
{
if(ms == null || !Util.equals(s.first(), ms.first()))
return false;
@@ -63,7 +63,7 @@ public int hashCode(){ if(_hash == -1)
{
int hash = 1;
- for(ISeq s = seq(); s != null; s = s.rest())
+ for(ISeq s = seq(); s != null; s = s.next())
{
hash = 31 * hash + (s.first() == null ? 0 : s.first().hashCode());
}
@@ -97,7 +97,7 @@ public int hashCode(){ public int count(){
int i = 1;
- for(ISeq s = rest(); s != null; s = s.rest(), i++)
+ for(ISeq s = next(); s != null; s = s.next(), i++)
;
return i;
}
@@ -111,9 +111,9 @@ public ISeq cons(Object o){ }
public Sequence more(){
- ISeq s = rest();
+ ISeq s = next();
if(s == null)
- return PersistentList.EMPTY;
+ return LazySeq.EMPTY;
return s;
}
@@ -167,7 +167,7 @@ public Object[] toArray(Object[] a){ if(a.length >= count())
{
ISeq s = seq();
- for(int i = 0; s != null; ++i, s = s.rest())
+ for(int i = 0; s != null; ++i, s = s.next())
{
a[i] = s.first();
}
@@ -188,7 +188,7 @@ public boolean isEmpty(){ }
public boolean contains(Object o){
- for(ISeq s = seq(); s != null; s = s.rest())
+ for(ISeq s = seq(); s != null; s = s.next())
{
if(Util.equiv(s.first(), o))
return true;
@@ -218,7 +218,7 @@ public IStream stream() throws Exception { if(s != null)
{
Object ret = s.first();
- s = s.rest();
+ s = s.next();
return ret;
}
return RT.eos();
@@ -245,7 +245,7 @@ public Object remove(int index){ public int indexOf(Object o){
ISeq s = seq();
- for(int i = 0; s != null; s = s.rest(), i++)
+ for(int i = 0; s != null; s = s.next(), i++)
{
if(Util.equiv(s.first(), o))
return i;
diff --git a/src/jvm/clojure/lang/ArraySeq.java b/src/jvm/clojure/lang/ArraySeq.java index bbe3b199..0373dd43 100644 --- a/src/jvm/clojure/lang/ArraySeq.java +++ b/src/jvm/clojure/lang/ArraySeq.java @@ -65,7 +65,7 @@ public Object first(){ return Reflector.prepRet(Array.get(array, i)); } -public ISeq rest(){ +public ISeq next(){ if(oa != null) { if(i + 1 < oa.length) @@ -138,7 +138,7 @@ static public class ArraySeq_int extends ASeq implements IndexedSeq, IReduce{ return array[i]; } - public ISeq rest(){ + public ISeq next(){ if(i + 1 < array.length) return new ArraySeq_int(meta(), array, i + 1); return null; @@ -186,7 +186,7 @@ static public class ArraySeq_float extends ASeq implements IndexedSeq, IReduce{ return array[i]; } - public ISeq rest(){ + public ISeq next(){ if(i + 1 < array.length) return new ArraySeq_float(meta(), array, i + 1); return null; @@ -233,7 +233,7 @@ static public class ArraySeq_double extends ASeq implements IndexedSeq, IReduce{ return array[i]; } - public ISeq rest(){ + public ISeq next(){ if(i + 1 < array.length) return new ArraySeq_double(meta(), array, i + 1); return null; @@ -280,7 +280,7 @@ static public class ArraySeq_long extends ASeq implements IndexedSeq, IReduce{ return array[i]; } - public ISeq rest(){ + public ISeq next(){ if(i + 1 < array.length) return new ArraySeq_long(meta(), array, i + 1); return null; diff --git a/src/jvm/clojure/lang/Compiler.java b/src/jvm/clojure/lang/Compiler.java index b29876f7..820223bc 100644 --- a/src/jvm/clojure/lang/Compiler.java +++ b/src/jvm/clojure/lang/Compiler.java @@ -749,12 +749,12 @@ static public abstract class HostExpr implements Expr, MaybePrimitiveExpr{ } else { - ISeq call = (ISeq) ((RT.third(form) instanceof ISeq) ? RT.third(form) : RT.rest(RT.rest(form))); + ISeq call = (ISeq) ((RT.third(form) instanceof ISeq) ? RT.third(form) : RT.next(RT.next(form))); if(!(RT.first(call) instanceof Symbol)) throw new IllegalArgumentException("Malformed member expression"); Symbol sym = (Symbol) RT.first(call); PersistentVector args = PersistentVector.EMPTY; - for(ISeq s = RT.rest(call); s != null; s = s.rest()) + for(ISeq s = RT.next(call); s != null; s = s.next()) args = args.cons(analyze(context == C.EVAL ? context : C.EXPRESSION, s.first())); if(c != null) return new StaticMethodExpr(source, line, c, sym.name, args); @@ -1804,7 +1804,7 @@ public static class TryExpr implements Expr{ int retLocal = getAndIncLocalNum(); int finallyLocal = getAndIncLocalNum(); - for(ISeq fs = form.rest(); fs != null; fs = fs.rest()) + for(ISeq fs = form.next(); fs != null; fs = fs.next()) { Object f = fs.first(); Object op = (f instanceof ISeq) ? ((ISeq) f).first() : null; @@ -1837,7 +1837,7 @@ public static class TryExpr implements Expr{ LocalBinding lb = registerLocal(sym, (Symbol) (RT.second(f) instanceof Symbol ? RT.second(f) : null), null); - Expr handler = (new BodyExpr.Parser()).parse(context, RT.rest(RT.rest(RT.rest(f)))); + Expr handler = (new BodyExpr.Parser()).parse(context, RT.next(RT.next(RT.next(f)))); catches = catches.cons(new CatchClause(c, lb, handler)); } finally @@ -1848,12 +1848,12 @@ public static class TryExpr implements Expr{ } else //finally { - if(fs.rest() != null) + if(fs.next() != null) throw new Exception("finally clause must be last in try expression"); try { Var.pushThreadBindings(RT.map(IN_CATCH_FINALLY, RT.T)); - finallyExpr = (new BodyExpr.Parser()).parse(C.STATEMENT, RT.rest(f)); + finallyExpr = (new BodyExpr.Parser()).parse(C.STATEMENT, RT.next(f)); } finally { @@ -2026,7 +2026,7 @@ static int getMatchingParams(String methodName, ArrayList<Class[]> paramlists, I { boolean match = true; ISeq aseq = argexprs.seq(); - for(int p = 0; match && p < argexprs.count() && aseq != null; ++p, aseq = aseq.rest()) + for(int p = 0; match && p < argexprs.count() && aseq != null; ++p, aseq = aseq.next()) { Expr arg = (Expr) aseq.first(); Class aclass = arg.hasJavaClass() ? arg.getJavaClass() : Object.class; @@ -2162,7 +2162,7 @@ public static class NewExpr implements Expr{ if(c == null) throw new IllegalArgumentException("Unable to resolve classname: " + RT.second(form)); PersistentVector args = PersistentVector.EMPTY; - for(ISeq s = RT.rest(RT.rest(form)); s != null; s = s.rest()) + for(ISeq s = RT.next(RT.next(form)); s != null; s = s.next()) args = args.cons(analyze(context == C.EVAL ? context : C.EXPRESSION, s.first())); return new NewExpr(c, args, line); } @@ -2562,7 +2562,7 @@ public static class MapExpr implements Expr{ static public Expr parse(C context, IPersistentMap form) throws Exception{ IPersistentVector keyvals = PersistentVector.EMPTY; - for(ISeq s = RT.seq(form); s != null; s = s.rest()) + for(ISeq s = RT.seq(form); s != null; s = s.next()) { IMapEntry e = (IMapEntry) s.first(); keyvals = (IPersistentVector) keyvals.cons(analyze(context == C.EVAL ? context : C.EXPRESSION, e.key())); @@ -2611,7 +2611,7 @@ public static class SetExpr implements Expr{ static public Expr parse(C context, IPersistentSet form) throws Exception{ IPersistentVector keys = PersistentVector.EMPTY; - for(ISeq s = RT.seq(form); s != null; s = s.rest()) + for(ISeq s = RT.seq(form); s != null; s = s.next()) { Object e = s.first(); keys = (IPersistentVector) keys.cons(analyze(context == C.EVAL ? context : C.EXPRESSION, e)); @@ -2747,7 +2747,7 @@ static class InvokeExpr implements Expr{ context = C.EXPRESSION; Expr fexpr = analyze(context, form.first()); PersistentVector args = PersistentVector.EMPTY; - for(ISeq s = RT.seq(form.rest()); s != null; s = s.rest()) + for(ISeq s = RT.seq(form.next()); s != null; s = s.next()) { args = args.cons(analyze(context, s.first())); } @@ -2929,17 +2929,17 @@ static public class FnExpr implements Expr{ if(RT.second(form) instanceof Symbol) { fn.thisName = ((Symbol) RT.second(form)).name; - form = RT.cons(FN, RT.rest(RT.rest(form))); + form = RT.cons(FN, RT.next(RT.next(form))); } //now (fn [args] body...) or (fn ([args] body...) ([args2] body2...) ...) //turn former into latter if(RT.second(form) instanceof IPersistentVector) - form = RT.list(FN, RT.rest(form)); + form = RT.list(FN, RT.next(form)); fn.line = (Integer) LINE.get(); FnMethod[] methodArray = new FnMethod[MAX_POSITIONAL_ARITY + 1]; FnMethod variadicMethod = null; - for(ISeq s = RT.rest(form); s != null; s = RT.rest(s)) + for(ISeq s = RT.next(form); s != null; s = RT.next(s)) { FnMethod f = FnMethod.parse(fn, (ISeq) RT.first(s)); if(f.isVariadic()) @@ -2994,7 +2994,7 @@ static public class FnExpr implements Expr{ if(closes.count() == 0) return ARG_TYPES[0]; PersistentVector tv = PersistentVector.EMPTY; - for(ISeq s = RT.keys(closes); s != null; s = s.rest()) + for(ISeq s = RT.keys(closes); s != null; s = s.next()) { LocalBinding lb = (LocalBinding) s.first(); if(lb.getPrimitiveType() != null) @@ -3089,7 +3089,7 @@ static public class FnExpr implements Expr{ clinitgen.endMethod(); // clinitgen.visitMaxs(1, 1); //instance fields for closed-overs - for(ISeq s = RT.keys(closes); s != null; s = s.rest()) + for(ISeq s = RT.keys(closes); s != null; s = s.next()) { LocalBinding lb = (LocalBinding) s.first(); if(lb.getPrimitiveType() != null) @@ -3124,7 +3124,7 @@ static public class FnExpr implements Expr{ else ctorgen.invokeConstructor(aFnType, afnctor); int a = 1; - for(ISeq s = RT.keys(closes); s != null; s = s.rest(), ++a) + for(ISeq s = RT.keys(closes); s != null; s = s.next(), ++a) { LocalBinding lb = (LocalBinding) s.first(); ctorgen.loadThis(); @@ -3164,7 +3164,7 @@ static public class FnExpr implements Expr{ ctorgen.endMethod(); //override of invoke/doInvoke for each method - for(ISeq s = RT.seq(methods); s != null; s = s.rest()) + for(ISeq s = RT.seq(methods); s != null; s = s.next()) { FnMethod method = (FnMethod) s.first(); method.emit(this, cv); @@ -3227,7 +3227,7 @@ static public class FnExpr implements Expr{ void emitClearCloses(GeneratorAdapter gen){ int a = 1; - for(ISeq s = RT.keys(closes); s != null; s = s.rest(), ++a) + for(ISeq s = RT.keys(closes); s != null; s = s.next(), ++a) { LocalBinding lb = (LocalBinding) s.first(); Class primc = lb.getPrimitiveType(); @@ -3269,7 +3269,7 @@ static public class FnExpr implements Expr{ getCompiledClass(); gen.newInstance(fntype); gen.dup(); - for(ISeq s = RT.keys(closes); s != null; s = s.rest()) + for(ISeq s = RT.keys(closes); s != null; s = s.next()) { LocalBinding lb = (LocalBinding) s.first(); if(lb.getPrimitiveType() != null) @@ -3443,7 +3443,7 @@ public static class FnMethod{ private static FnMethod parse(FnExpr fn, ISeq form) throws Exception{ //([args] body...) IPersistentVector parms = (IPersistentVector) RT.first(form); - ISeq body = RT.rest(form); + ISeq body = RT.next(form); try { FnMethod method = new FnMethod(fn, (FnMethod) METHOD.get()); @@ -3527,7 +3527,7 @@ public static class FnMethod{ body.emit(C.RETURN, fn, gen); Label end = gen.mark(); gen.visitLocalVariable("this", "Ljava/lang/Object;", null, loopLabel, end, 0); - for(ISeq lbs = argLocals.seq(); lbs != null; lbs = lbs.rest()) + for(ISeq lbs = argLocals.seq(); lbs != null; lbs = lbs.next()) { LocalBinding lb = (LocalBinding) lbs.first(); gen.visitLocalVariable(lb.name, "Ljava/lang/Object;", null, loopLabel, end, lb.idx); @@ -3661,12 +3661,12 @@ public static class BodyExpr implements Expr{ public Expr parse(C context, Object frms) throws Exception{ ISeq forms = (ISeq) frms; if(Util.equals(RT.first(forms), DO)) - forms = RT.rest(forms); + forms = RT.next(forms); PersistentVector exprs = PersistentVector.EMPTY; - for(; forms != null; forms = forms.rest()) + for(; forms != null; forms = forms.next()) { Expr e = (context != C.EVAL && - (context == C.STATEMENT || forms.rest() != null)) ? + (context == C.STATEMENT || forms.next() != null)) ? analyze(C.STATEMENT, forms.first()) : analyze(context, forms.first()); @@ -3752,7 +3752,7 @@ public static class LetExpr implements Expr{ if((bindings.count() % 2) != 0) throw new IllegalArgumentException("Bad binding form, expected matched symbol expression pairs"); - ISeq body = RT.rest(RT.rest(form)); + ISeq body = RT.next(RT.next(form)); if(context == C.EVAL || (context == C.EXPRESSION && isLoop)) @@ -3835,7 +3835,7 @@ public static class LetExpr implements Expr{ body.emit(context, fn, gen); Label end = gen.mark(); // gen.visitLocalVariable("this", "Ljava/lang/Object;", null, loopLabel, end, 0); - for(ISeq bis = bindingInits.seq(); bis != null; bis = bis.rest()) + for(ISeq bis = bindingInits.seq(); bis != null; bis = bis.next()) { BindingInit bi = (BindingInit) bis.first(); String lname = bi.binding.name; @@ -3931,7 +3931,7 @@ public static class RecurExpr implements Expr{ if(IN_CATCH_FINALLY.get() != null) throw new UnsupportedOperationException("Cannot recur from catch/finally"); PersistentVector args = PersistentVector.EMPTY; - for(ISeq s = RT.seq(form.rest()); s != null; s = s.rest()) + for(ISeq s = RT.seq(form.next()); s != null; s = s.next()) { args = args.cons(analyze(C.EXPRESSION, s.first())); } @@ -4090,7 +4090,7 @@ public static Object macroexpand1(Object x) throws Exception{ try { Var.pushThreadBindings(RT.map(RT.MACRO_META, RT.meta(form))); - return v.applyTo(form.rest()); + return v.applyTo(form.next()); } finally { @@ -4115,7 +4115,7 @@ public static Object macroexpand1(Object x) throws Exception{ { target = RT.list(IDENTITY, target); } - return RT.listStar(DOT, target, meth, form.rest().rest()); + return RT.listStar(DOT, target, meth, form.next().next()); } else if(namesStaticMember(sym)) { @@ -4124,7 +4124,7 @@ public static Object macroexpand1(Object x) throws Exception{ if(c != null) { Symbol meth = Symbol.intern(sym.name); - return RT.listStar(DOT, target, meth, form.rest()); + return RT.listStar(DOT, target, meth, form.next()); } } else @@ -4141,7 +4141,7 @@ public static Object macroexpand1(Object x) throws Exception{ //(StringBuilder. "foo") => (new StringBuilder "foo") //else if(idx == sname.length() - 1) - return RT.listStar(NEW, Symbol.intern(sname.substring(0, idx)), form.rest()); + return RT.listStar(NEW, Symbol.intern(sname.substring(0, idx)), form.next()); } } } @@ -4164,9 +4164,9 @@ private static Expr analyzeSeq(C context, ISeq form, String name) throws Excepti Object op = RT.first(form); if(op == null) throw new IllegalArgumentException("Can't call nil"); - IFn inline = isInline(op, RT.count(RT.rest(form))); + IFn inline = isInline(op, RT.count(RT.next(form))); if(inline != null) - return analyze(context, inline.applyTo(RT.rest(form))); + return analyze(context, inline.applyTo(RT.next(form))); IParser p; if(op.equals(FN)) return FnExpr.parse(context, form, name); diff --git a/src/jvm/clojure/lang/Cons.java b/src/jvm/clojure/lang/Cons.java index a7fb5c09..9606094e 100644 --- a/src/jvm/clojure/lang/Cons.java +++ b/src/jvm/clojure/lang/Cons.java @@ -33,13 +33,13 @@ public Object first(){ return _first; } -public ISeq rest(){ +public ISeq next(){ return more().seq(); } public Sequence more(){ if(_more == null) - return PersistentList.EMPTY; + return LazySeq.EMPTY; return _more; } diff --git a/src/jvm/clojure/lang/Delay.java b/src/jvm/clojure/lang/Delay.java index 53569e43..cfaad693 100644 --- a/src/jvm/clojure/lang/Delay.java +++ b/src/jvm/clojure/lang/Delay.java @@ -56,7 +56,7 @@ public class Delay { public int count() { int c = 0; - for (ISeq s = seq(); s != null; s = s.rest()) + for (ISeq s = seq(); s != null; s = s.next()) ++c; return c; } @@ -127,7 +127,7 @@ public class Delay { if (a.length >= count()) { ISeq s = seq(); - for (int i = 0; s != null; ++i, s = s.rest()) + for (int i = 0; s != null; ++i, s = s.next()) { a[i] = s.first(); } @@ -148,7 +148,7 @@ public class Delay { } public boolean contains(Object o) { - for (ISeq s = seq(); s != null; s = s.rest()) + for (ISeq s = seq(); s != null; s = s.next()) { if (Util.equiv(s.first(), o)) return true; @@ -179,7 +179,7 @@ public class Delay { public int indexOf(Object o) { ISeq s = seq(); - for (int i = 0; s != null; s = s.rest(), i++) + for (int i = 0; s != null; s = s.next(), i++) { if (Util.equiv(s.first(), o)) return i; diff --git a/src/jvm/clojure/lang/EnumerationSeq.java b/src/jvm/clojure/lang/EnumerationSeq.java index 7c579651..33485e40 100644 --- a/src/jvm/clojure/lang/EnumerationSeq.java +++ b/src/jvm/clojure/lang/EnumerationSeq.java @@ -18,7 +18,7 @@ public class EnumerationSeq extends ASeq{ final Enumeration iter; final State state; -static class State{ + static class State{ volatile Object val; volatile Object _rest; } @@ -52,7 +52,7 @@ public Object first(){ return state.val; } -public ISeq rest(){ +public ISeq next(){ if(state._rest == state) synchronized(state) { diff --git a/src/jvm/clojure/lang/ISeq.java b/src/jvm/clojure/lang/ISeq.java index e608bbf7..6637b0bf 100644 --- a/src/jvm/clojure/lang/ISeq.java +++ b/src/jvm/clojure/lang/ISeq.java @@ -20,7 +20,7 @@ public interface ISeq extends Sequence{ Object first();
-ISeq rest();
+ISeq next();
Sequence more();
diff --git a/src/jvm/clojure/lang/IteratorSeq.java b/src/jvm/clojure/lang/IteratorSeq.java index 4a5ab80c..a510d53f 100644 --- a/src/jvm/clojure/lang/IteratorSeq.java +++ b/src/jvm/clojure/lang/IteratorSeq.java @@ -16,7 +16,7 @@ public class IteratorSeq extends ASeq{ final Iterator iter;
final State state;
-static class State{
+ static class State{
volatile Object val;
volatile Object _rest;
}
@@ -50,7 +50,7 @@ public Object first(){ return state.val;
}
-public ISeq rest(){
+public ISeq next(){
if(state._rest == state)
synchronized(state)
{
diff --git a/src/jvm/clojure/lang/LazyCons.java b/src/jvm/clojure/lang/LazyCons.java index ee60a891..515cd2e9 100644 --- a/src/jvm/clojure/lang/LazyCons.java +++ b/src/jvm/clojure/lang/LazyCons.java @@ -49,7 +49,7 @@ public Object first(){ final synchronized -public ISeq rest(){ +public ISeq next(){ if(_rest == sentinel) { try @@ -72,7 +72,7 @@ public LazyCons withMeta(IPersistentMap meta){ if(meta == meta()) return this; //force before copying - rest(); + next(); return new LazyCons(meta, _first, _rest); } } diff --git a/src/jvm/clojure/lang/LazySeq.java b/src/jvm/clojure/lang/LazySeq.java index f06faed5..05d8f030 100644 --- a/src/jvm/clojure/lang/LazySeq.java +++ b/src/jvm/clojure/lang/LazySeq.java @@ -16,8 +16,17 @@ import java.util.*; public class LazySeq extends AFn implements List, Sequence { static final ISeq DUMMY = new Cons(null, null); + static final LazySeq EMPTY = new LazySeq(null); - private ISeq s = DUMMY; + private ISeq s; + + public LazySeq() { + this(DUMMY); + } + + LazySeq(ISeq s) { + this.s = s; + } final synchronized public ISeq seq() { if(s == DUMMY) @@ -36,7 +45,7 @@ public class LazySeq extends AFn implements List, Sequence { public int count() { int c = 0; - for (ISeq s = seq(); s != null; s = s.rest()) + for (ISeq s = seq(); s != null; s = s.next()) ++c; return c; } @@ -107,7 +116,7 @@ public class LazySeq extends AFn implements List, Sequence { if (a.length >= count()) { ISeq s = seq(); - for (int i = 0; s != null; ++i, s = s.rest()) + for (int i = 0; s != null; ++i, s = s.next()) { a[i] = s.first(); } @@ -128,7 +137,7 @@ public class LazySeq extends AFn implements List, Sequence { } public boolean contains(Object o) { - for (ISeq s = seq(); s != null; s = s.rest()) + for (ISeq s = seq(); s != null; s = s.next()) { if (Util.equiv(s.first(), o)) return true; @@ -159,7 +168,7 @@ public class LazySeq extends AFn implements List, Sequence { public int indexOf(Object o) { ISeq s = seq(); - for (int i = 0; s != null; s = s.rest(), i++) + for (int i = 0; s != null; s = s.next(), i++) { if (Util.equiv(s.first(), o)) return i; diff --git a/src/jvm/clojure/lang/LispReader.java b/src/jvm/clojure/lang/LispReader.java index 49400339..ecca2b32 100644 --- a/src/jvm/clojure/lang/LispReader.java +++ b/src/jvm/clojure/lang/LispReader.java @@ -744,7 +744,7 @@ public static class SyntaxQuoteReader extends AFn{ private static ISeq sqExpandList(ISeq seq) throws Exception{
PersistentVector ret = PersistentVector.EMPTY;
- for(; seq != null; seq = seq.rest())
+ for(; seq != null; seq = seq.next())
{
Object item = seq.first();
if(isUnquote(item))
@@ -759,7 +759,7 @@ public static class SyntaxQuoteReader extends AFn{ private static IPersistentVector flattenMap(Object form){
IPersistentVector keyvals = PersistentVector.EMPTY;
- for(ISeq s = RT.seq(form); s != null; s = s.rest())
+ for(ISeq s = RT.seq(form); s != null; s = s.next())
{
IMapEntry e = (IMapEntry) s.first();
keyvals = (IPersistentVector) keyvals.cons(e.key());
@@ -915,18 +915,18 @@ public static class EvalReader extends AFn{ }
if(fs.name.endsWith("."))
{
- Object[] args = RT.toArray(RT.rest(o));
+ Object[] args = RT.toArray(RT.next(o));
return Reflector.invokeConstructor(RT.classForName(fs.name.substring(0, fs.name.length() - 1)), args);
}
if(Compiler.namesStaticMember(fs))
{
- Object[] args = RT.toArray(RT.rest(o));
+ Object[] args = RT.toArray(RT.next(o));
return Reflector.invokeStaticMethod(fs.ns, fs.name, args);
}
Object v = Compiler.maybeResolveIn(Compiler.currentNS(), fs);
if(v instanceof Var)
{
- return ((IFn) v).applyTo(RT.rest(o));
+ return ((IFn) v).applyTo(RT.next(o));
}
throw new Exception("Can't resolve " + fs);
}
diff --git a/src/jvm/clojure/lang/MultiFn.java b/src/jvm/clojure/lang/MultiFn.java index bb818da4..f144a59d 100644 --- a/src/jvm/clojure/lang/MultiFn.java +++ b/src/jvm/clojure/lang/MultiFn.java @@ -65,12 +65,12 @@ private boolean prefers(Object x, Object y) throws Exception{ IPersistentSet xprefs = (IPersistentSet) getPreferTable().valAt(x); if(xprefs != null && xprefs.contains(y)) return true; - for(ISeq ps = RT.seq(parents.invoke(y)); ps != null; ps = ps.rest()) + for(ISeq ps = RT.seq(parents.invoke(y)); ps != null; ps = ps.next()) { if(prefers(x, ps.first())) return true; } - for(ISeq ps = RT.seq(parents.invoke(x)); ps != null; ps = ps.rest()) + for(ISeq ps = RT.seq(parents.invoke(x)); ps != null; ps = ps.next()) { if(prefers(ps.first(), y)) return true; diff --git a/src/jvm/clojure/lang/Numbers.java b/src/jvm/clojure/lang/Numbers.java index 4a49c8cb..c1f2b830 100644 --- a/src/jvm/clojure/lang/Numbers.java +++ b/src/jvm/clojure/lang/Numbers.java @@ -15,12 +15,6 @@ package clojure.lang; import java.math.BigInteger; import java.math.BigDecimal; import java.math.MathContext; -import java.util.concurrent.Executor; -import java.util.concurrent.Executors; -import java.util.concurrent.Callable; -import java.util.concurrent.ExecutorService; -import java.util.LinkedList; -import java.util.Arrays; public class Numbers{ @@ -1422,7 +1416,7 @@ static BitOps bitOps(Object x){ else { ISeq s = RT.seq(init); - for(int i = 0; i < size && s != null; i++, s = s.rest()) + for(int i = 0; i < size && s != null; i++, s = s.next()) ret[i] = ((Number) s.first()).floatValue(); } return ret; @@ -1436,7 +1430,7 @@ static BitOps bitOps(Object x){ ISeq s = RT.seq(sizeOrSeq); int size = s.count(); float[] ret = new float[size]; - for(int i = 0; i < size && s != null; i++, s = s.rest()) + for(int i = 0; i < size && s != null; i++, s = s.next()) ret[i] = ((Number) s.first()).floatValue(); return ret; } @@ -1453,7 +1447,7 @@ static public double[] double_array(int size, Object init){ else { ISeq s = RT.seq(init); - for(int i = 0; i < size && s != null; i++, s = s.rest()) + for(int i = 0; i < size && s != null; i++, s = s.next()) ret[i] = ((Number) s.first()).doubleValue(); } return ret; @@ -1467,7 +1461,7 @@ static public double[] double_array(Object sizeOrSeq){ ISeq s = RT.seq(sizeOrSeq); int size = s.count(); double[] ret = new double[size]; - for(int i = 0; i < size && s != null; i++, s = s.rest()) + for(int i = 0; i < size && s != null; i++, s = s.next()) ret[i] = ((Number) s.first()).doubleValue(); return ret; } @@ -1484,7 +1478,7 @@ static public int[] int_array(int size, Object init){ else { ISeq s = RT.seq(init); - for(int i = 0; i < size && s != null; i++, s = s.rest()) + for(int i = 0; i < size && s != null; i++, s = s.next()) ret[i] = ((Number) s.first()).intValue(); } return ret; @@ -1498,7 +1492,7 @@ static public int[] int_array(Object sizeOrSeq){ ISeq s = RT.seq(sizeOrSeq); int size = s.count(); int[] ret = new int[size]; - for(int i = 0; i < size && s != null; i++, s = s.rest()) + for(int i = 0; i < size && s != null; i++, s = s.next()) ret[i] = ((Number) s.first()).intValue(); return ret; } @@ -1515,7 +1509,7 @@ static public long[] long_array(int size, Object init){ else { ISeq s = RT.seq(init); - for(int i = 0; i < size && s != null; i++, s = s.rest()) + for(int i = 0; i < size && s != null; i++, s = s.next()) ret[i] = ((Number) s.first()).longValue(); } return ret; @@ -1529,7 +1523,7 @@ static public long[] long_array(Object sizeOrSeq){ ISeq s = RT.seq(sizeOrSeq); int size = s.count(); long[] ret = new long[size]; - for(int i = 0; i < size && s != null; i++, s = s.rest()) + for(int i = 0; i < size && s != null; i++, s = s.next()) ret[i] = ((Number) s.first()).longValue(); return ret; } diff --git a/src/jvm/clojure/lang/PersistentArrayMap.java b/src/jvm/clojure/lang/PersistentArrayMap.java index d8fbd354..6f212b9b 100644 --- a/src/jvm/clojure/lang/PersistentArrayMap.java +++ b/src/jvm/clojure/lang/PersistentArrayMap.java @@ -216,7 +216,7 @@ static class Seq extends ASeq{ return new MapEntry(array[i],array[i+1]);
}
- public ISeq rest(){
+ public ISeq next(){
if(i + 2 < array.length)
return new Seq(array, i + 2);
return null;
diff --git a/src/jvm/clojure/lang/PersistentHashMap.java b/src/jvm/clojure/lang/PersistentHashMap.java index d696cd5a..0705ffd7 100644 --- a/src/jvm/clojure/lang/PersistentHashMap.java +++ b/src/jvm/clojure/lang/PersistentHashMap.java @@ -93,9 +93,9 @@ public static PersistentHashMap create(List init){ static public PersistentHashMap create(ISeq items){ IPersistentMap ret = EMPTY; - for(; items != null; items = items.rest().rest()) + for(; items != null; items = items.next().next()) { - if(items.rest() == null) + if(items.next() == null) throw new IllegalArgumentException(String.format("No value supplied for key: %s", items.first())); ret = ret.assoc(items.first(), RT.second(items)); } @@ -349,8 +349,8 @@ final static class FullNode implements INode{ return s.first(); } - public ISeq rest(){ - ISeq nexts = s.rest(); + public ISeq next(){ + ISeq nexts = s.next(); if(nexts != null) return new Seq(nexts, i, node); return create(node, i + 1); @@ -359,7 +359,7 @@ final static class FullNode implements INode{ public Seq withMeta(IPersistentMap meta){ return new Seq(meta, s, i, node); } - } + } } @@ -507,8 +507,8 @@ final static class BitmapIndexedNode implements INode{ return s.first(); } - public ISeq rest(){ - ISeq nexts = s.rest(); + public ISeq next(){ + ISeq nexts = s.next(); if(nexts != null) return new Seq(nexts, i, node); return create(node, i + 1); @@ -517,7 +517,7 @@ final static class BitmapIndexedNode implements INode{ public Seq withMeta(IPersistentMap meta){ return new Seq(meta, s, i, node); } - } + } } diff --git a/src/jvm/clojure/lang/PersistentHashSet.java b/src/jvm/clojure/lang/PersistentHashSet.java index a06b826c..35c6fa95 100644 --- a/src/jvm/clojure/lang/PersistentHashSet.java +++ b/src/jvm/clojure/lang/PersistentHashSet.java @@ -13,8 +13,6 @@ package clojure.lang; import java.util.List; -import java.util.Iterator; -import java.util.Collection; public class PersistentHashSet extends APersistentSet{ @@ -40,7 +38,7 @@ public static PersistentHashSet create(List init){ static public PersistentHashSet create(ISeq items){ PersistentHashSet ret = EMPTY; - for(; items != null; items = items.rest()) + for(; items != null; items = items.next()) { ret = (PersistentHashSet) ret.cons(items.first()); } diff --git a/src/jvm/clojure/lang/PersistentList.java b/src/jvm/clojure/lang/PersistentList.java index fabe5e1e..f6efd69a 100644 --- a/src/jvm/clojure/lang/PersistentList.java +++ b/src/jvm/clojure/lang/PersistentList.java @@ -29,7 +29,7 @@ public static IFn creator = new RestFn(0){ return ret;
}
LinkedList list = new LinkedList();
- for(ISeq s = RT.seq(args); s != null; s = s.rest())
+ for(ISeq s = RT.seq(args); s != null; s = s.next())
list.add(s.first());
return create(list);
}
@@ -64,7 +64,7 @@ public Object first(){ return _first;
}
-public ISeq rest(){
+public ISeq next(){
if(_count == 1)
return null;
return (ISeq) _rest;
@@ -100,21 +100,20 @@ public PersistentList withMeta(IPersistentMap meta){ public Object reduce(IFn f) throws Exception{
Object ret = first();
- for(ISeq s = rest(); s != null; s = s.rest())
+ for(ISeq s = next(); s != null; s = s.next())
ret = f.invoke(ret, s.first());
return ret;
}
public Object reduce(IFn f, Object start) throws Exception{
Object ret = f.invoke(start, first());
- for(ISeq s = rest(); s != null; s = s.rest())
+ for(ISeq s = next(); s != null; s = s.next())
ret = f.invoke(ret, s.first());
return ret;
}
-
-static class EmptyList extends Obj implements IPersistentList, List, Sequence{
+ static class EmptyList extends Obj implements IPersistentList, List, Sequence{
public int hashCode(){
return 1;
@@ -249,7 +248,7 @@ static class EmptyList extends Obj implements IPersistentList, List, Sequence{ public int indexOf(Object o){
ISeq s = seq();
- for(int i = 0; s != null; s = s.rest(), i++)
+ for(int i = 0; s != null; s = s.next(), i++)
{
if(Util.equiv(s.first(), o))
return i;
diff --git a/src/jvm/clojure/lang/PersistentQueue.java b/src/jvm/clojure/lang/PersistentQueue.java index 552cdb42..655b3e41 100644 --- a/src/jvm/clojure/lang/PersistentQueue.java +++ b/src/jvm/clojure/lang/PersistentQueue.java @@ -42,12 +42,12 @@ public boolean equiv(Object obj){ if(!(obj instanceof Sequential))
return false;
ISeq ms = RT.seq(obj);
- for(ISeq s = seq(); s != null; s = s.rest(), ms = ms.rest())
+ for(ISeq s = seq(); s != null; s = s.next(), ms = ms.next())
{
if(ms == null || !Util.equiv(s.first(), ms.first()))
return false;
}
- return ms.rest() == null;
+ return ms.next() == null;
}
@@ -56,12 +56,12 @@ public boolean equals(Object obj){ if(!(obj instanceof Sequential))
return false;
ISeq ms = RT.seq(obj);
- for(ISeq s = seq(); s != null; s = s.rest(), ms = ms.rest())
+ for(ISeq s = seq(); s != null; s = s.next(), ms = ms.next())
{
if(ms == null || !Util.equals(s.first(), ms.first()))
return false;
}
- return ms.rest() == null;
+ return ms.next() == null;
}
@@ -69,7 +69,7 @@ public int hashCode(){ if(_hash == -1)
{
int hash = 0;
- for(ISeq s = seq(); s != null; s = s.rest())
+ for(ISeq s = seq(); s != null; s = s.next())
{
hash = Util.hashCombine(hash, Util.hash(s.first()));
}
@@ -86,7 +86,7 @@ public PersistentQueue pop(){ if(f == null) //hmmm... pop of empty queue -> empty queue?
return this;
//throw new IllegalStateException("popping empty queue");
- ISeq f1 = f.rest();
+ ISeq f1 = f.next();
PersistentVector r1 = r;
if(f1 == null)
{
@@ -140,8 +140,8 @@ static class Seq extends ASeq{ return f.first();
}
- public ISeq rest(){
- ISeq f1 = f.rest();
+ public ISeq next(){
+ ISeq f1 = f.next();
ISeq r1 = rseq;
if(f1 == null)
{
@@ -205,7 +205,7 @@ public Object[] toArray(Object[] a){ if(a.length >= count())
{
ISeq s = seq();
- for(int i = 0; s != null; ++i, s = s.rest())
+ for(int i = 0; s != null; ++i, s = s.next())
{
a[i] = s.first();
}
@@ -226,7 +226,7 @@ public boolean isEmpty(){ }
public boolean contains(Object o){
- for(ISeq s = seq(); s != null; s = s.rest())
+ for(ISeq s = seq(); s != null; s = s.next())
{
if(Util.equiv(s.first(), o))
return true;
diff --git a/src/jvm/clojure/lang/PersistentStructMap.java b/src/jvm/clojure/lang/PersistentStructMap.java index 01e86346..3ce43073 100644 --- a/src/jvm/clojure/lang/PersistentStructMap.java +++ b/src/jvm/clojure/lang/PersistentStructMap.java @@ -37,7 +37,7 @@ static public Def createSlotMap(ISeq keys){ throw new IllegalArgumentException("Must supply keys"); PersistentHashMap ret = PersistentHashMap.EMPTY; int i = 0; - for(ISeq s = keys; s != null; s = s.rest(), i++) + for(ISeq s = keys; s != null; s = s.next(), i++) { ret = (PersistentHashMap) ret.assoc(s.first(), i); } @@ -47,9 +47,9 @@ static public Def createSlotMap(ISeq keys){ static public PersistentStructMap create(Def def, ISeq keyvals){ Object[] vals = new Object[def.keyslots.count()]; IPersistentMap ext = PersistentHashMap.EMPTY; - for(; keyvals != null; keyvals = keyvals.rest().rest()) + for(; keyvals != null; keyvals = keyvals.next().next()) { - if(keyvals.rest() == null) + if(keyvals.next() == null) throw new IllegalArgumentException(String.format("No value supplied for key: %s", keyvals.first())); Object k = keyvals.first(); Object v = RT.second(keyvals); @@ -65,7 +65,7 @@ static public PersistentStructMap create(Def def, ISeq keyvals){ static public PersistentStructMap construct(Def def, ISeq valseq){ Object[] vals = new Object[def.keyslots.count()]; IPersistentMap ext = PersistentHashMap.EMPTY; - for(int i = 0; i < vals.length && valseq != null; valseq = valseq.rest(), i++) + for(int i = 0; i < vals.length && valseq != null; valseq = valseq.next(), i++) { vals[i] = valseq.first(); } @@ -216,9 +216,9 @@ static class Seq extends ASeq{ return new MapEntry(keys.first(), vals[i]); } - public ISeq rest(){ + public ISeq next(){ if(i + 1 < vals.length) - return new Seq(_meta, keys.rest(), vals, i + 1, ext); + return new Seq(_meta, keys.next(), vals, i + 1, ext); return ext.seq(); } } diff --git a/src/jvm/clojure/lang/PersistentTreeMap.java b/src/jvm/clojure/lang/PersistentTreeMap.java index 1cd40969..5a5a9bee 100644 --- a/src/jvm/clojure/lang/PersistentTreeMap.java +++ b/src/jvm/clojure/lang/PersistentTreeMap.java @@ -69,9 +69,9 @@ PersistentTreeMap(IPersistentMap meta, Comparator comp, Node tree, int _count){ static public PersistentTreeMap create(ISeq items){ IPersistentMap ret = EMPTY; - for(; items != null; items = items.rest().rest()) + for(; items != null; items = items.next().next()) { - if(items.rest() == null) + if(items.next() == null) throw new IllegalArgumentException(String.format("No value supplied for key: %s", items.first())); ret = ret.assoc(items.first(), RT.second(items)); } @@ -80,9 +80,9 @@ static public PersistentTreeMap create(ISeq items){ static public PersistentTreeMap create(Comparator comp, ISeq items){ IPersistentMap ret = new PersistentTreeMap(comp); - for(; items != null; items = items.rest().rest()) + for(; items != null; items = items.next().next()) { - if(items.rest() == null) + if(items.next() == null) throw new IllegalArgumentException(String.format("No value supplied for key: %s", items.first())); ret = ret.assoc(items.first(), RT.second(items)); } @@ -781,9 +781,9 @@ static public class Seq extends ASeq{ return stack.first(); } - public ISeq rest(){ + public ISeq next(){ Node t = (Node) stack.first(); - ISeq nextstack = push(asc ? t.right() : t.left(), stack.rest(), asc); + ISeq nextstack = push(asc ? t.right() : t.left(), stack.next(), asc); if(nextstack != null) { return new Seq(nextstack, asc, cnt - 1); diff --git a/src/jvm/clojure/lang/PersistentTreeSet.java b/src/jvm/clojure/lang/PersistentTreeSet.java index 3fca1c68..f6f50125 100644 --- a/src/jvm/clojure/lang/PersistentTreeSet.java +++ b/src/jvm/clojure/lang/PersistentTreeSet.java @@ -13,9 +13,7 @@ package clojure.lang; import java.util.List; -import java.util.Iterator; import java.util.Comparator; -import java.util.Collection; public class PersistentTreeSet extends APersistentSet implements Reversible, Sorted{ static public final PersistentTreeSet EMPTY = new PersistentTreeSet(null, PersistentTreeMap.EMPTY); @@ -40,7 +38,7 @@ public static PersistentTreeSet create(List init){ static public PersistentTreeSet create(ISeq items){ PersistentTreeSet ret = EMPTY; - for(; items != null; items = items.rest()) + for(; items != null; items = items.next()) { ret = (PersistentTreeSet) ret.cons(items.first()); } diff --git a/src/jvm/clojure/lang/PersistentVector.java b/src/jvm/clojure/lang/PersistentVector.java index 2a0256f1..9b8e40da 100644 --- a/src/jvm/clojure/lang/PersistentVector.java +++ b/src/jvm/clojure/lang/PersistentVector.java @@ -37,7 +37,6 @@ package clojure.lang; import java.util.List; -import java.util.Collection; public class PersistentVector extends APersistentVector{ final int cnt; @@ -50,7 +49,7 @@ public final static PersistentVector EMPTY = new PersistentVector(0, 5, RT.EMPTY static public PersistentVector create(ISeq items){ PersistentVector ret = EMPTY; - for(; items != null; items = items.rest()) + for(; items != null; items = items.next()) ret = ret.cons(items.first()); return ret; } diff --git a/src/jvm/clojure/lang/RT.java b/src/jvm/clojure/lang/RT.java index ab7e7938..1c8b30f5 100644 --- a/src/jvm/clojure/lang/RT.java +++ b/src/jvm/clojure/lang/RT.java @@ -560,24 +560,24 @@ static public Object first(Object x){ } static public Object second(Object x){ - return first(rest(x)); + return first(next(x)); } static public Object third(Object x){ - return first(rest(rest(x))); + return first(next(next(x))); } static public Object fourth(Object x){ - return first(rest(rest(rest(x)))); + return first(next(next(next(x)))); } -static public ISeq rest(Object x){ +static public ISeq next(Object x){ if(x instanceof ISeq) - return ((ISeq) x).rest(); + return ((ISeq) x).next(); ISeq seq = seq(x); if(seq == null) return null; - return seq.rest(); + return seq.next(); } static public Sequence more(Object x){ @@ -585,7 +585,7 @@ static public Sequence more(Object x){ return ((ISeq) x).more(); ISeq seq = seq(x); if(seq == null) - return PersistentList.EMPTY; + return LazySeq.EMPTY; return seq.more(); } @@ -606,10 +606,6 @@ static public Sequence more(Object x){ // return ret; //} -static public ISeq rrest(Object x){ - return rest(rest(x)); -} - static public Object peek(Object x){ if(x == null) return null; @@ -722,12 +718,12 @@ static public Object find(Object coll, Object key){ static public ISeq findKey(Keyword key, ISeq keyvals) throws Exception{ while(keyvals != null) { - ISeq r = keyvals.rest(); + ISeq r = keyvals.next(); if(r == null) throw new Exception("Malformed keyword argslist"); if(keyvals.first() == key) return r; - keyvals = r.rest(); + keyvals = r.next(); } return null; } @@ -766,7 +762,7 @@ static public Object nth(Object coll, int n){ { ISeq seq = RT.seq(coll); coll = null; - for(int i = 0; i <= n && seq != null; ++i, seq = seq.rest()) + for(int i = 0; i <= n && seq != null; ++i, seq = seq.next()) { if(i == n) return seq.first(); @@ -829,7 +825,7 @@ static public Object nth(Object coll, int n, Object notFound){ { ISeq seq = RT.seq(coll); coll = null; - for(int i = 0; i <= n && seq != null; ++i, seq = seq.rest()) + for(int i = 0; i <= n && seq != null; ++i, seq = seq.next()) { if(i == n) return seq.first(); @@ -1106,7 +1102,7 @@ static public Object[] toArray(Object coll) throws Exception{ { ISeq s = (seq(coll)); Object[] ret = new Object[count(s)]; - for(int i = 0; i < ret.length; i++, s = s.rest()) + for(int i = 0; i < ret.length; i++, s = s.next()) ret[i] = s.first(); return ret; } @@ -1117,7 +1113,7 @@ static public Object[] toArray(Object coll) throws Exception{ static public Object[] seqToArray(ISeq seq){ int len = length(seq); Object[] ret = new Object[len]; - for(int i = 0; seq != null; ++i, seq = seq.rest()) + for(int i = 0; seq != null; ++i, seq = seq.next()) ret[i] = seq.first(); return ret; } @@ -1129,14 +1125,14 @@ static public Object seqToTypedArray(ISeq seq) throws Exception{ static public Object seqToTypedArray(Class type, ISeq seq) throws Exception{ Object ret = Array.newInstance(type, length(seq)); - for(int i = 0; seq != null; ++i, seq = seq.rest()) + for(int i = 0; seq != null; ++i, seq = seq.next()) Array.set(ret, i, seq.first()); return ret; } static public int length(ISeq list){ int i = 0; - for(ISeq c = list; c != null; c = c.rest()) + for(ISeq c = list; c != null; c = c.next()) { i++; } @@ -1145,7 +1141,7 @@ static public int length(ISeq list){ static public int boundedLength(ISeq list, int limit) throws Exception{ int i = 0; - for(ISeq c = list; c != null && i <= limit; c = c.rest()) + for(ISeq c = list; c != null && i <= limit; c = c.next()) { i++; } @@ -1309,13 +1305,13 @@ static public void print(Object x, Writer w) throws Exception{ else if(x instanceof IPersistentMap) { w.write('{'); - for(ISeq s = seq(x); s != null; s = s.rest()) + for(ISeq s = seq(x); s != null; s = s.next()) { IMapEntry e = (IMapEntry) s.first(); print(e.key(), w); w.write(' '); print(e.val(), w); - if(s.rest() != null) + if(s.next() != null) w.write(", "); } w.write('}'); @@ -1335,10 +1331,10 @@ static public void print(Object x, Writer w) throws Exception{ else if(x instanceof IPersistentSet) { w.write("#{"); - for(ISeq s = seq(x); s != null; s = s.rest()) + for(ISeq s = seq(x); s != null; s = s.next()) { print(s.first(), w); - if(s.rest() != null) + if(s.next() != null) w.write(" "); } w.write('}'); @@ -1397,10 +1393,10 @@ static public void print(Object x, Writer w) throws Exception{ } private static void printInnerSeq(ISeq x, Writer w) throws Exception{ - for(ISeq s = x; s != null; s = s.rest()) + for(ISeq s = x; s != null; s = s.next()) { print(s.first(), w); - if(s.rest() != null) + if(s.next() != null) w.write(' '); } } @@ -1484,13 +1480,13 @@ static public ISeq doFormat(Writer w, String s, ISeq args) throws Exception{ if(args == null) throw new IllegalArgumentException("Missing argument"); RT.formatAesthetic(w, RT.first(args)); - args = RT.rest(args); + args = RT.next(args); break; case 's': if(args == null) throw new IllegalArgumentException("Missing argument"); RT.formatStandard(w, RT.first(args)); - args = RT.rest(args); + args = RT.next(args); break; case '{': int j = s.indexOf("~}", i); //note - does not nest @@ -1499,7 +1495,7 @@ static public ISeq doFormat(Writer w, String s, ISeq args) throws Exception{ String subs = s.substring(i, j); for(ISeq sargs = RT.seq(RT.first(args)); sargs != null;) sargs = doFormat(w, subs, sargs); - args = RT.rest(args); + args = RT.next(args); i = j + 2; //skip ~} break; case '^': diff --git a/src/jvm/clojure/lang/Range.java b/src/jvm/clojure/lang/Range.java index 226a77ba..8976e852 100644 --- a/src/jvm/clojure/lang/Range.java +++ b/src/jvm/clojure/lang/Range.java @@ -39,7 +39,7 @@ public Object first(){ return n; } -public ISeq rest(){ +public ISeq next(){ if(n < end-1) return new Range(_meta, n + 1, end); return null; diff --git a/src/jvm/clojure/lang/RestFn.java b/src/jvm/clojure/lang/RestFn.java index f9ea3ed7..4e15f799 100644 --- a/src/jvm/clojure/lang/RestFn.java +++ b/src/jvm/clojure/lang/RestFn.java @@ -142,254 +142,254 @@ public Object applyTo(ISeq args) throws Exception{ return doInvoke(args);
case 1:
return doInvoke(args.first()
- , args.rest());
+ , args.next());
case 2:
return doInvoke(args.first()
- , (args = args.rest()).first()
- , args.rest());
+ , (args = args.next()).first()
+ , args.next());
case 3:
return doInvoke(args.first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , args.rest());
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , args.next());
case 4:
return doInvoke(args.first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , args.rest());
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , args.next());
case 5:
return doInvoke(args.first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , args.rest());
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , args.next());
case 6:
return doInvoke(args.first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , args.rest());
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , args.next());
case 7:
return doInvoke(args.first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , args.rest());
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , args.next());
case 8:
return doInvoke(args.first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , args.rest());
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , args.next());
case 9:
return doInvoke(args.first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , args.rest());
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , args.next());
case 10:
return doInvoke(args.first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , args.rest());
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , args.next());
case 11:
return doInvoke(args.first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , args.rest());
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , args.next());
case 12:
return doInvoke(args.first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , args.rest());
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , args.next());
case 13:
return doInvoke(args.first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , args.rest());
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , args.next());
case 14:
return doInvoke(args.first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , args.rest());
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , args.next());
case 15:
return doInvoke(args.first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , args.rest());
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , args.next());
case 16:
return doInvoke(args.first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , args.rest());
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , args.next());
case 17:
return doInvoke(args.first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , args.rest());
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , args.next());
case 18:
return doInvoke(args.first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , args.rest());
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , args.next());
case 19:
return doInvoke(args.first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , args.rest());
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , args.next());
case 20:
return doInvoke(args.first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , args.rest());
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , args.next());
}
return throwArity();
@@ -1324,9 +1324,9 @@ protected static ISeq findKey(Object key, ISeq args){ while(args != null)
{
if(key == args.first())
- return args.rest();
- args = RT.rest(args);
- args = RT.rest(args);
+ return args.next();
+ args = RT.next(args);
+ args = RT.next(args);
}
return null;
}
diff --git a/src/jvm/clojure/lang/SeqEnumeration.java b/src/jvm/clojure/lang/SeqEnumeration.java index 42b7f198..bdff3a17 100644 --- a/src/jvm/clojure/lang/SeqEnumeration.java +++ b/src/jvm/clojure/lang/SeqEnumeration.java @@ -27,7 +27,7 @@ public boolean hasMoreElements(){ public Object nextElement(){ Object ret = RT.first(seq); - seq = RT.rest(seq); + seq = RT.next(seq); return ret; } } diff --git a/src/jvm/clojure/lang/SeqIterator.java b/src/jvm/clojure/lang/SeqIterator.java index 6a09c5c1..ea8b7a25 100644 --- a/src/jvm/clojure/lang/SeqIterator.java +++ b/src/jvm/clojure/lang/SeqIterator.java @@ -31,7 +31,7 @@ public Object next() throws NoSuchElementException { if(seq == null) throw new NoSuchElementException(); Object ret = RT.first(seq); - seq = RT.rest(seq); + seq = RT.next(seq); return ret; } diff --git a/src/jvm/clojure/lang/StreamSeq.java b/src/jvm/clojure/lang/StreamSeq.java index 44cfe28c..fca82d7a 100644 --- a/src/jvm/clojure/lang/StreamSeq.java +++ b/src/jvm/clojure/lang/StreamSeq.java @@ -41,7 +41,7 @@ public class StreamSeq extends ASeq { return _first; } - synchronized public ISeq rest() { + synchronized public ISeq next() { if (stream != null) { try { _rest = create(stream); @@ -56,7 +56,7 @@ public class StreamSeq extends ASeq { public Obj withMeta(IPersistentMap meta) { if(meta != this.meta()) { - rest(); + next(); return new StreamSeq(meta, _first, _rest); } return this; diff --git a/src/jvm/clojure/lang/StringSeq.java b/src/jvm/clojure/lang/StringSeq.java index cf370224..b5622903 100644 --- a/src/jvm/clojure/lang/StringSeq.java +++ b/src/jvm/clojure/lang/StringSeq.java @@ -38,7 +38,7 @@ public Object first(){ return Character.valueOf(s.charAt(i)); } -public ISeq rest(){ +public ISeq next(){ if(i + 1 < s.length()) return new StringSeq(_meta, s, i + 1); return null; diff --git a/src/jvm/clojure/lang/Var.java b/src/jvm/clojure/lang/Var.java index dfc0436c..a900e5da 100644 --- a/src/jvm/clojure/lang/Var.java +++ b/src/jvm/clojure/lang/Var.java @@ -264,7 +264,7 @@ synchronized public Object alterRoot(IFn fn, ISeq args) throws Exception{ public static void pushThreadBindings(Associative bindings){ Frame f = dvals.get(); Associative bmap = f.bindings; - for(ISeq bs = bindings.seq(); bs != null; bs = bs.rest()) + for(ISeq bs = bindings.seq(); bs != null; bs = bs.next()) { IMapEntry e = (IMapEntry) bs.first(); Var v = (Var) e.key(); @@ -279,7 +279,7 @@ public static void popThreadBindings(){ Frame f = dvals.get(); if(f.prev == null) throw new IllegalStateException("Pop without matching push"); - for(ISeq bs = RT.keys(f.frameBindings); bs != null; bs = bs.rest()) + for(ISeq bs = RT.keys(f.frameBindings); bs != null; bs = bs.next()) { Var v = (Var) bs.first(); v.count.decrementAndGet(); @@ -291,7 +291,7 @@ public static void releaseThreadBindings(){ Frame f = dvals.get(); if(f.prev == null) throw new IllegalStateException("Release without full unwind"); - for(ISeq bs = RT.keys(f.bindings); bs != null; bs = bs.rest()) + for(ISeq bs = RT.keys(f.bindings); bs != null; bs = bs.next()) { Var v = (Var) bs.first(); v.count.decrementAndGet(); |