Looking at it as
(. f applyTo (seq args))
The object instance of IFn 'f' calls the method 'applyTo' with sequence
'args'.
>From http://clojure.org/java_interop
(*.* instance-expr member-symbol)(*.* instance-expr (method-symbol args*))
or(*.* instance-expr method-symbol args*)
That makes p
drclj writes:
> Thanks everyone, in the apply function source code I see
>
> ([^clojure.lang.IFn f args]
> (. f (applyTo (seq args
>
> Seems the (applyTo (seq args)) returns arg parameters,
>
> And the f is invoked only once:
>
> (. f args)
I think you’re missing that `.` is a special form w
Is there an implicit question there? If so, does this
(https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/IFn.java)
help?
'(Devin Walters)
On Aug 10, 2013, at 10:55 PM, drclj wrote:
> Thanks everyone, in the apply function source code I see
>
> ([^clojure.lang.IFn f args]
>
Thanks everyone, in the apply function source code I see
([^clojure.lang.IFn f args]
(. f (applyTo (seq args
Seems the (applyTo (seq args)) returns arg parameters,
And the f is invoked only once:
(. f args)
--
--
You received this message because you are subscribed to the Goo
When you write (apply inc [4 5]) it's like
(inc 4 5)
But the inc function accepts only one argument.
--
--
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 f
How many args does inc supports ? Only one.
(apply inc [ 1 3 ]) is the same as (inc 1 3) which would also trigger an arity
exception.
apply does not call the given fn on each item in the collection it's given,
it calls it once with the whole collection as the argument list.
(map inc
(apply str [2 3]) does the same thing as (str 2 3), which is to attempt to
convert each of its args to a string, then concatenate them all.
(apply inc [4 5]) does the same thing as (inc 4 5), which is to throw an
exception because inc takes exactly one argument and returns that value
plus 1
Hi there:
Why does
(apply str [2 3]) work
and not
(apply inc [4 5])
though
(apply inc [4])
does work?
Thanks.
--
--
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