On Fri, Mar 21, 2014 at 3:55 PM, Andy Smith <the4thamig...@googlemail.com>wrote:
> I came across the following issue when doing problem
>
> user=> (let [f '(+ 1 1)] (apply (first f) (rest f)))
> 1

That's interesting. It seems it's the last form in the list that's being
returned, and it doesn't matter what function you apply

(apply '+ '(2 1))   ;=> 1
(apply '+ '(1 2))   ;=> 2
(apply 'map '(2 1)) ;=> 1

I don't have any immediate thoughts on why it behaves like that, though
I'm sure there's a reason (?).

> I could use eval but eval is bad (apparently)...

You could use clojure.core/resolve instead, I think that should be safe.

(let [f '(+ 1 1)]
  (apply (resolve (first f) (rest f))))
;=> 2

--
John Mastro

-- 
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/d/optout.

Reply via email to