2015-08-13 10:08 GMT+02:00 Eric Le Goff <eleg...@gmail.com>:

> I would be curious to know if there are difference (in terms of
> performance / elegance ) between those 2 ways of expressing functions
>
> E.g
>
> *(fn [& x] (-> x sort last))*
>
> versus
>
> *#(last (sort %&))*
>
> Both are supposedly equivalent, but would you recommend one preferred
> syntax , or this just a matter of personal style ?
>

#() is for very short functions, mostly just one-liners, where the (fn [])
would add significant noise.
The line is blurry and a matter of taste; upper limit is when you need a
nested fn, since #(#()) is not possible.
Performance is equivalent, since #() desugars into (fn [..]).

2015-08-13 10:14 GMT+02:00 Erik Assum <e...@assum.net>:

> (comp last sort)
>

That's not the same function as #(last (sort %&))
The equivalent would be (comp last sort vec)

cheers

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