Essentially, apply just removes the parens (or brackets) from your list of
args and creates the original function call:

(apply  +  [1 2 3])  ->  (+ 1 2 3)

Alan Thompson

On Tue, Mar 26, 2013 at 12:49 PM, Alan Thompson <thompson2...@gmail.com>wrote:

> Apply works for any number of args:
>
>  (apply + [1 2 3 4 5])
>
> He just gave you an example inline function of 2 args since that was the
> original example.
> Alan Thompson
>
>
> On Tue, Mar 26, 2013 at 12:44 PM, Ryan <arekand...@gmail.com> wrote:
>
>> Thanks Michael, but If i am not mistaken, your example only works with a
>> vector with two elements. What if we have an unknown number of vector
>> elements?
>> My apologies if that wasn't clear on my first post.
>>
>> On Tuesday, March 26, 2013 9:38:55 PM UTC+2, Michael Klishin wrote:
>>>
>>>
>>> 2013/3/26 Ryan <areka...@gmail.com>
>>>
>>>> What i am trying to do is to apply the elements of my vector as
>>>> arguments to the function. How can I achieve this?
>>>
>>>
>>> user=> (apply (fn [a b] (println a b)) [:a :b])
>>> :a :b
>>> nil
>>>
>>> --
>>> MK
>>>
>>> http://github.com/**michaelklishin <http://github.com/michaelklishin>
>>> http://twitter.com/**michaelklishin <http://twitter.com/michaelklishin>
>>>
>>  --
>> --
>> 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
>> ---
>> You received this message because you are subscribed to the Google Groups
>> "Clojure" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to clojure+unsubscr...@googlegroups.com.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>>
>>
>
>

-- 
-- 
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
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to