On Tue, Aug 11, 2009 at 6:39 AM, Krukow <karl.kru...@gmail.com> wrote:

>
> I was browsing through core when I noticed something I didn't
> understand in 'into' (from core.clj):
>
> ;redef into with batch support
> (defn into
>  "Returns a new coll consisting of to-coll with all of the items of
>  from-coll conjoined."
>  [to from]
>  (if (instance? clojure.lang.IEditableCollection to)
>    (#(loop [ret (transient to) items (seq from)]
>        (if items
>          (recur (conj! ret (first items)) (next items))
>          (persistent! ret))))
>    (#(loop [ret to items (seq from)]
>        (if items
>          (recur (conj ret (first items)) (next items))
>          ret)))))
>
> I am wondering about the construct #(loop ...). As far as I can see
> you might as well just use (loop). I.e.,
>
> (defn into2
>  "Returns a new coll consisting of to-coll with all of the items of
>  from-coll conjoined."
>  [to from]
>  (if (instance? clojure.lang.IEditableCollection to)
>    (loop [ret (transient to) items (seq from)]
>        (if items
>          (recur (conj! ret (first items)) (next items))
>          (persistent! ret)))
>    (loop [ret to items (seq from)]
>        (if items
>          (recur (conj ret (first items)) (next items))
>          ret))))
>
> I suspect that I am missing some point. Could someone clarify?
>

I don't know. Perhaps at this point during bootstrap loop doesn't create
recur points and so the anonymous lambdas are necessary? But then recur
would rebind the (nonexistent) lambda parameters I'd have thought.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to