Re: areduce flaw

2009-04-28 Thread Boris Mizhen
Thanks Rich, > What's correct is what is documented here: http://clojure.org/java_interop RTFM is still very relevant :) Boris --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group,

Re: areduce flaw

2009-04-28 Thread Rich Hickey
On Apr 27, 4:26 pm, Boris Mizhen wrote: > Hello all, > It seems to me that areduce can not be used with an anonymous array. > Consider: > > (areduce (.. System getProperties values toArray) i r 0 > (some_expression)) > > It seems to me that there is no way to get i'th element of the array > in

Re: areduce flaw

2009-04-28 Thread Rich Hickey
On Apr 27, 10:04 pm, Boris Mizhen wrote: > Thanks to all who replied. > > To summarize what I learned - Clojure has a special form (. ) to > *call* java functions, but does not have concept of a *value* > corresponding to a java function. > This makes Java functions a second class citizen :) >

Re: areduce flaw

2009-04-27 Thread Boris Mizhen
Thanks to all who replied. To summarize what I learned - Clojure has a special form (. ) to *call* java functions, but does not have concept of a *value* corresponding to a java function. This makes Java functions a second class citizen :) In addition special forms are expanded in the first pos

Re: areduce flaw

2009-04-27 Thread Timothy Pratley
> How can I pass a static java function to another function? There is also memfn: (memfn name & args) Macro Expands into code that creates a fn that expects to be passed an object and any args and calls the named instance method on the object passing the args. Use when you want to treat a Java me

Re: areduce flaw

2009-04-27 Thread Stuart Sierra
On Apr 27, 5:51 pm, Boris Mizhen wrote: > I wonder if someone could explain or point me to the explanation about > *why* a Java static fn can't be passed just like a closure fn? The only reason I can give you is that Java methods aren't first-class objects, like Clojure fns. The (.method object

Re: areduce flaw

2009-04-27 Thread Kevin Downey
no, the syntax is not the same. user=> (macroexpand-1 '(.foo bar)) (. bar foo) On Mon, Apr 27, 2009 at 2:51 PM, Boris Mizhen wrote: > > Hi Meikel, thanks for the answer. > > I wonder if someone could explain or point me to the explanation about > *why* a Java static fn can't be passed just li

Re: areduce flaw

2009-04-27 Thread Boris Mizhen
Hi Meikel, thanks for the answer. I wonder if someone could explain or point me to the explanation about *why* a Java static fn can't be passed just like a closure fn? After all the syntax to call them is the same :) Thanks, Boris On Apr 27, 5:34 pm, Meikel Brandmeyer wrote: > Hi, > > Am 27.

Re: areduce flaw

2009-04-27 Thread Meikel Brandmeyer
Hi, Am 27.04.2009 um 23:17 schrieb Boris Mizhen: ((comp #(Math/abs %) +) -3 -4) => 7 How can I pass a static java function to another function? Here you already gave the answer to your question. Wrap it in a Clojure fn/#(). A member function must be trickier because this must be supplied,

Re: areduce flaw

2009-04-27 Thread Boris Mizhen
I suspect I will be asking more questions, so in order not to start another thread I will post below :) Why ((comp - +) -3 -4) => 7 but ((comp Math/abs +) -3 -4) => Error? java.lang.Exception: No such namespace: Math (NO_SOURCE_FILE:1) [Thrown class clojure.lang.Compiler$CompilerException] a