Re: Applying Java functions

2011-06-18 Thread Lars Rune Nøstdal
Hi, user> (definline sqrt [x] `(Math/sqrt ~x)) #'user/sqrt user> (map sqrt (range 1 10)) (1.0 1.4142135623730951 1.7320508075688772 2.0 2.23606797749979 2.449489742783178 2.6457513110645907 2.8284271247461903 3.0) -- http://www.nostdal.org/ -- You received this message because you ar

Re: Applying Java functions

2011-06-17 Thread Konrad Hinsen
On 18 Jun, 2011, at 1:12 , Michael Gardner wrote: > On Jun 17, 2011, at 3:44 AM, Konrad Hinsen wrote: > >> Java methods aren't even first-class objects (nor, in fact, objects at all) >> in the Java world. Clojure can hardly do better than Java in unifying things >> at the JVM level. The one thi

Re: Applying Java functions

2011-06-17 Thread Michael Gardner
On Jun 17, 2011, at 3:44 AM, Konrad Hinsen wrote: > Java methods aren't even first-class objects (nor, in fact, objects at all) > in the Java world. Clojure can hardly do better than Java in unifying things > at the JVM level. The one thing that you can do with a method in Java is call > it, an

Re: Applying Java functions

2011-06-17 Thread de1976
Thanks. It really is amazing how non "functional" Java is. Makes me glad there are now languages that do their best to correct that. -- 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 tha

Re: Applying Java functions

2011-06-17 Thread Konrad Hinsen
On 17 Jun, 2011, at 9:20 , Ken Wesson wrote: >> Shouldn't it be possible to apply Math/sqrt directly? If I use a >> function from the clojure.core, I can do it: >> user=> (map str (range 1 10)) >> ("1" "2" "3" "4" "5" "6" "7" "8" "9") > > Java methods aren't first-class functions, so they can't b

Re: Applying Java functions

2011-06-17 Thread Ken Wesson
On Fri, Jun 17, 2011 at 2:59 AM, de1976 wrote: > Hi everyone. Ran into an interesting case here when trying stuff out > in the REPL. > > user=> (Math/sqrt 4) > 2.0 > > user=> (map #(Math/sqrt %) (range 1 10)) > (1.0 1.4142135623730951 ..) > > user=> (map Math/sqrt (range 1 10)) > java.lang.Exc

Applying Java functions

2011-06-17 Thread de1976
Hi everyone. Ran into an interesting case here when trying stuff out in the REPL. user=> (Math/sqrt 4) 2.0 user=> (map #(Math/sqrt %) (range 1 10)) (1.0 1.4142135623730951 ..) user=> (map Math/sqrt (range 1 10)) java.lang.Exception: Unable to find static field: sqrt in class java.lang.Math (