Re: JavaCode with static class methods
Alexander Burger writes: Hi Joe, Hi Alex, >> I'm experimenting a bit with the 'java' function, and the StringBuilder >> ... >> (java "java.lang.Math" 'sqrt 4) > > It needs a different call: >: (java "java.lang.Math" 'sqrt (-6 . 64.0)) thanks for the hints, so actually I was pretty close, just ignorant about the peculiarities of those numeric arguments. -- cheers, Thorsten -- UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
Re: JavaCode with static class methods
Hi Thorsten, > I'm experimenting a bit with the 'java' function, and the StringBuilder > ... > (java "java.lang.Math" 'sqrt 4) It needs a different call: : (scl 6) -> 6 : (java "java.lang.Math" 'sqrt (-6 . 64.0)) -> 800 : (round @) -> "8.000" As you probably know, the Java interface is described in http://picolisp.com/wiki/?javacode It writes: While integers are directly passed to/from the JVM, other number formats can be passed to the JVM as cons pairs consisting of an ID in the CAR and the value in the CDR. These are: • 1 for Byte • 2 for Char • 3 for Short • 4 for Integer (default, usually not needed) • 8 for Long • 9 for BigInteger If the CAR is a negative number, the value is taken as a double scaled by the negated number of digits. ♪♫ Alex -- UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
Re: JavaCode with static class methods
Hi Thorsen, it looks like you were on the right path. I'm guessing there may be a bug or issue with the double signature This works: : (java (java "java.lang.Math" "abs" -4)) -> 4 : (java (java "java.lang.Math" "min" 10 5)) -> 5 But I'm just guessing On Thu, Mar 2, 2017 at 3:02 PM, Thorsten Jolitz wrote: > > Hi List, > > I'm experimenting a bit with the 'java' function, and the StringBuilder > and GregorianCalendar example from the JavaCode Wiki entry work fine, > but I wonder how to use a constructorless class like e.g. java.lang.Math > with its static class methods? > > #+NAME: JavaCode - none of these work > #+BEGIN_SRC picolisp > (java "java.lang.Math" 'sqrt 4) > (java java.lang.Math 'sqrt 4) > (java 'java.lang.Math 'sqrt 4) > > (setq M (java "java.lang.Math" T)) // returns null, no constructor > #+END_SRC > > Thanks for any hints. > > -- > cheers, > Thorsten > > -- > UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe >
JavaCode with static class methods
Hi List, I'm experimenting a bit with the 'java' function, and the StringBuilder and GregorianCalendar example from the JavaCode Wiki entry work fine, but I wonder how to use a constructorless class like e.g. java.lang.Math with its static class methods? #+NAME: JavaCode - none of these work #+BEGIN_SRC picolisp (java "java.lang.Math" 'sqrt 4) (java java.lang.Math 'sqrt 4) (java 'java.lang.Math 'sqrt 4) (setq M (java "java.lang.Math" T)) // returns null, no constructor #+END_SRC Thanks for any hints. -- cheers, Thorsten -- UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe