On Mon, 28 Jun 2010 13:31:45 -0500
Savanni D'Gerinel <sava...@alyra.org> wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> Along those lines, why is the apply necessary?
> 
> More clearly, and I encountered this with a different block of code
> earlier today, repeat returns a lazy sequence.  Str does nothing to
> evaluate that sequences, so (str (repeat ...)) returns a lazy sequence.

str applys .toString to it's arguments, and then concatenates the
results together. .toString of a lazy sequence is an internal token
that you can use to infer it's from a lazy sequence, and that's about
it.

> Why does (apply str (repeat ...)) evaluate the sequence?  The
> documentation for apply does not mention that it will do so.

apply turns the values in sequence into arguments to a call to
str. For example, (apply str ["a" "b" "c"]) evaluates (str "a" "b" "c").
Since function arguments are passed by value (you can't apply a
macro), the lazy sequence has to be evaluated out to the end.

> Generally I am having a lot of trouble with sequences because I am never
> clear on when a lazy sequence will be evaluated strictly.

Sorry if this was already answered; I found it and realized I hadn't
seen an answer yet.

     <mike
-- 
Mike Meyer <m...@mired.org>             http://www.mired.org/consulting.html
Independent Network/Unix/Perforce consultant, email for more information.

O< ascii ribbon campaign - stop html mail - www.asciiribbon.org

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