On Wed, Mar 28, 2012 at 7:16 PM, Timothy Baldridge <tbaldri...@gmail.com> wrote:
> "May be delayed"
>
> But I don't think they ever are:
>
> user=> (def oddseq (map #(do (print %) %) (range 30)))
> #'user/oddseq
>
> user=> (defn foo [& args] 'd)
> #'user/foo
>
> user=> (apply foo oddseq)
> 01234567891011121314151617181920212223242526272829d
>
> user=> (def oddseq (map #(do (print %) %) (range 1)))
> #'user/oddseq
>
> user=> (apply foo oddseq)
> 0d
>
> user=>
>
> I don't think it's possible to ever have apply not evaluate all its
> arguments? I think this is what Nathan was saying. Given the above
> example, is there anyway to not have the side effects automatically
> run when invoking apply?

Range is chunked, and I think the map-generated sequence inherits
that. On the other hand, I thought the chunk size was 16, and that it
didn't matter anyway if no element was ever requested. On the gripping
hand, (apply f x) calls (seq x), which realizes the first element (and
thus the first chunk, for chunked seqs) to determine if x is empty and
it should therefore return nil.

-- 
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