Hi Mark and Baishampayan,

I can see what difference it makes, but I can't get a handle on the 
rationale. For instance, I found this discussion:
http://stackoverflow.com/questions/1257028/why-should-i-use-apply-in-clojure

It starts with a quote from a Rich Hickey blog post, as follows.

> A big difference between Clojure and CL is that Clojure is a Lisp-1, so 
> funcall is not needed, and apply is only used to apply a function to a 
> runtime-defined collection of arguments. So, (apply f [i]) can be written 
> (f i).


But it can't, can it? In this context (apply f [i]) with respect to (f i)*
 apply *has *side-effects*!

Further on in the discussion, this example is given.

(+ [1 2 3 4 5])


which does not add the numbers. But

> (apply + [1 2 3 4 5])

does.

There seem to be inscrutabilities in the way arguments are handled in 
Clojure. The reason this is so troubling is that going the other way is so 
transparent. That is, a String is automatically converted to a sequence as 
required.
 

>  


On Saturday, 15 December 2012 20:39:04 UTC+10, Marko Topolnik wrote:
>
>
> I'm still puzzled about this though, because (doc str) says that with one 
>> argument x, str returns x.toString(). What it returns is
>> "clojure.lang.LazySeq@fe1"
>>
>> So it seems to be returning a lazy sequence. Why is the function not 
>> simply applied? Other functions are "applied" simple by expressing their 
>> form. 
>>
>
> No, it is returning exactly as advertised, the result of calling 
> #toString() on an instance of LazySeq.
>
> The difference between (str a-lazy-seq) and (apply str a-lazy-seq) is that 
> in the first case str is called with one argument, the lazy seq, and in the 
> second case with, say 5 arguments, for a lazy seq of length 5. The lazy seq 
> is *spliced* into separate arguments to str. 
>

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