On Sun, Dec 16, 2012 at 10:04 AM, Marko Topolnik
<marko.topol...@gmail.com>wrote:

>
> Well, why don't you start with my example? Try rewriting this without OP's
> *apply*, implemented here as #(%1 %2).
>
>  (defn apply-curried [f & args] (reduce #(%1 %2) f args))
>
>
>
To avoid confusion, I'm going to refer to the OP's conception of apply as
"funcall" versus Clojure's "apply".

Ok, I see your point that the concept of funcall can be a useful one.

However, the fact that you can write funcall so easily as #(%1 %2)
illustrates that funcall adds no real expressiveness to the language,
whereas apply is really fundamental to being able to pass lists to
multi-arg functions.  It's hard to imagine how to write apply at all if it
weren't built in to the language.

funcall, on the other hand, can be described easily as "funcall is a
function that takes a function f, and a value v and applies f to v".
We write funcall the exact same way we write any other "function that takes
a blah and blah and does blah":
(defn funcall [f v] (f v))
or as you noted, #(%1 %2).

Since we have a way to apply a function to a value (i.e., (f v)), if you
want a function that applies a function to a value, you can easily express
that using ordinary techniques, if needed.

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