coco <[email protected]> writes:
> thanks for the answer, well, I rewrote the function lik this:
>
> (defn recursive-reverse [coll]
> (loop [col coll mem '()]
> (if (empty? col)
> mem
> (recur (rest col) (cons (first col) mem)) )))
>
> I've a little logic problem but I fix it....
One minor remark: Instead of (empty? col) one usually uses (seq col),
which returns nil if col is empty and non-nil otherwise. (So you'd have
to swap the branches of the if.)
(defn recursive-reverse [coll]
(loop [col coll mem '()]
(if (seq col)
(recur (rest col) (cons (first col) mem))
mem)))
Bye,
Tassilo
--
(What the world needs (I think) is not
(a Lisp (with fewer parentheses))
but (an English (with more.)))
Brian Hayes, http://tinyurl.com/3y9l2kf
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en