Re: Why does the following Clojure code take 10x the time the C# version does? How to improve the Clojure version?

2015-05-20 Thread Amith George
Wow. This is rather hard to believe. But the execution time is now 10s. :D All of your suggestions were on the mark. I implemented them in stages/commits. The command to execute the file remains the same - `lein run -m rdp.214-intermediate-arr 1 true` 1. Replaced the coordinates vector with sep

Re: Why does the following Clojure code take 10x the time the C# version does? How to improve the Clojure version?

2015-05-20 Thread Amith George
Oh, a few more things I observed; - I figured out how to use *unchecked-math* and *warn-on-reflection* :) Earlier, I was setting them within a binding, but that didn't seem to do anything. Seems the correct way is to set them at the very top of the file, the first 2 lines after the namespace

Re: Adding JavaDocs for Interoperability with Java?

2015-05-20 Thread Timur Sungur
Thanks everyone for their helpful answers! On Wed, May 20, 2015 at 6:22 AM 'wparke...@yahoo.com' via Clojure < clojure@googlegroups.com> wrote: > A few other thoughts here: > > - To elaborate on Colin's suggestion a bit, if you define Java interfaces > in Java, it's easy to create a function that

Re: Why does the following Clojure code take 10x the time the C# version does? How to improve the Clojure version?

2015-05-20 Thread Leif
"Elapsed time: 1155.723592 msecs" I implemented the changes Amith and Steven suggested on my multithreaded version. I think we can safely say that, with a modest effort, Clojure can compare favorably to C#. :) https://gist.github.com/leifp/a864bca941ecdacb5840 Cheers, Leif On Tuesday, May 19,

Re: One more argument for cyclic dependencies

2015-05-20 Thread Justin Smith
I'll second the recommendation to use protocols or interfaces to solve this. Clojure is fairly opinionated in that the tools available should push you toward developing against interfaces or protocols rather than concrete implementations. Things become much simpler when you accept this. You can

Re: Why does the following Clojure code take 10x the time the C# version does? How to improve the Clojure version?

2015-05-20 Thread Steven Yi
Hi Amith, Very glad you're seeing the performance increase there too! I think you're right about both the extraneous type hints and the unchecked-math. I tend to turn on unchecked-math in a leiningen profile that I use while developing, but leave it set to default for normal builds. Because of th

Using @ alone

2015-05-20 Thread Pierre Thibault
Is possible to use the operator '@' alone? In the Joy Of Clojure book it is presented as '~@'. I would like an example. -- 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

Re: Using @ alone

2015-05-20 Thread Colin Yates
@my-atom is the same as (deref my-atom), is that what you mean? On 20 May 2015 23:35, "Pierre Thibault" wrote: > Is possible to use the operator '@' alone? In the Joy Of Clojure book it > is presented as '~@'. I would like an example. > > -- > You received this message because you are subscribed

Accessing static fields

2015-05-20 Thread Pierre Thibault
I can do Math/PI put how can I access PI if Math is in a expression like '(Math) for example? -- 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

Re: Using @ alone

2015-05-20 Thread Laurens Van Houtven
Hi Pierre, > On May 20, 2015, at 3:35 PM, Pierre Thibault > wrote: > > Is possible to use the operator '@' alone? In the Joy Of Clojure book it is > presented as '~@'. I would like an example. There are multiple contexts in which @ could be used. One is syntactic sugar for the deref functio

Re: Accessing static fields

2015-05-20 Thread Laurens Van Houtven
Hi Pierre, > On May 20, 2015, at 3:38 PM, Pierre Thibault > wrote: > > I can do Math/PI put how can I access PI if Math is in a expression like > '(Math) for example? Can you provide a more specific example? Math/PI is always Math/PI, it doesn’t change if you put it in a nested form/expressi

Re: Using @ alone

2015-05-20 Thread Pierre Thibault
For example: (def foo '(1 2 3)) (+ @foo) Does not work. I am expecting 6. Le mercredi 20 mai 2015 18:37:05 UTC-4, Colin Yates a écrit : > > @my-atom is the same as (deref my-atom), is that what you mean? > On 20 May 2015 23:35, "Pierre Thibault" > wrote: > >> Is possible to use the operator '@'

Re: Using @ alone

2015-05-20 Thread Pierre Thibault
OK, ~@ is one operator, I thought it was two different operators. Thank you. Le mercredi 20 mai 2015 18:38:50 UTC-4, Laurens Van Houtven a écrit : > > Hi Pierre, > > > On May 20, 2015, at 3:35 PM, Pierre Thibault > wrote: > > Is possible to use the operator '@' alone? In the Joy Of Clojure book

Re: Using @ alone

2015-05-20 Thread Colin Yates
@ (and deref) are used to dereference constructs which support multiple values over time; atoms, futures and promises etc. ~@ is a different thing entirely and is used to desplice lists in a macro. In your example, you aren't in a macro and '() is defining a set, I.e. it isn't a temperal construct

Re: Accessing static fields

2015-05-20 Thread Pierre Thibault
Hi Laurens, My example was not very good. Here another one: (.format (first '(String)) "%s" "foo") Imagine String is obtained dynamically. I guess then I have to use Java reflection to do a dynamic invocation. I guess I am confused because classes in Java are not objects. Le mercredi 20 mai 2

Re: Accessing static fields

2015-05-20 Thread Pierre Thibault
I gave it a try: (.. (class String) (getMethod "format" (into-array Class [String (Class/forName "[Ljava.lang.Object;")]))) But I am unable to get the method. I gave up. Le mercredi 20 mai 2015 19:12:05 UTC-4, Pierre Thibault a écrit : > > Hi Laurens, > > My example was not very good. Here anot

Re: Using @ alone

2015-05-20 Thread Pierre Thibault
OK, I don't know how to write macros yet. I was confused. Thank you. Le mercredi 20 mai 2015 18:48:03 UTC-4, Colin Yates a écrit : > > @ (and deref) are used to dereference constructs which support multiple > values over time; atoms, futures and promises etc. ~@ is a different thing > entirely

Re: Using @ alone

2015-05-20 Thread Colin Yates
That's OK, I am also confused between '() which is a literal list and #{} which is a literal set :). On 21 May 2015 00:55, "Pierre Thibault" wrote: > OK, > > I don't know how to write macros yet. I was confused. > > Thank you. > > Le mercredi 20 mai 2015 18:48:03 UTC-4, Colin Yates a écrit : >> >

Re: Using @ alone

2015-05-20 Thread Pierre Thibault
No: (type '()) clojure.lang.PersistentList$EmptyList It a list just like it should be. Le mercredi 20 mai 2015 20:02:22 UTC-4, Colin Yates a écrit : > > That's OK, I am also confused between '() which is a literal list and #{} > which is a literal set :). > On 21 May 2015 00:55, "Pierre Thibaul

Re: Accessing static fields

2015-05-20 Thread Ambrose Bonnaire-Sergeant
Yes, you must use Java reflection. Thanks, Ambrose On Thu, May 21, 2015 at 7:54 AM, Pierre Thibault wrote: > I gave it a try: > > (.. (class String) (getMethod "format" (into-array Class [String > (Class/forName "[Ljava.lang.Object;")]))) > > But I am unable to get the method. I gave up. > > >

Re: Accessing static fields

2015-05-20 Thread Keith Irwin
Not sure if this helps, but: user => (eval (symbol "Math" "PI”)) 3.141592653589793 user => (eval `(. ~(resolve (symbol "String")) ~(symbol "format") "%s" (to-array ["adasd"]))) “adasd" Maybe a macro of some sort? (defmacro invoke-static [c meth & args] `(. ~(resolve (symbol c)) ~(symbol m

[ANN] Demo of the Holy Grail workflow

2015-05-20 Thread Daniel Szmulewicz
Hi everybody, A video showcasing the Holy Grail workflow has been posted on youtube. https://www.youtube.com/watch?v=eoxsSrFK_Is The workflow is built on top of Boot , a build tool, and system , a component li

Re: Accessing static fields

2015-05-20 Thread Ambrose Bonnaire-Sergeant
Macros won't work because they are expanded at compile-time. We want to choose the method at runtime. Thanks, Ambrose On Thu, May 21, 2015 at 9:02 AM, Keith Irwin wrote: > Not sure if this helps, but: > > user => (eval (symbol "Math" "PI”)) > 3.141592653589793 > > user => (eval `(. ~(resolve (

Re: Accessing static fields

2015-05-20 Thread Keith Irwin
What about eval? user => (eval `(. ~(resolve (symbol "String")) ~(symbol "format") "%s" (to-array ["adasd"]))) “adasd" I have a function form: (defn static-invoke [c meth & args] (eval `(. ~(resolve (symbol c)) ~(symbol meth) ~@args))) Which works for some things: user => (static-invoke

Re: Accessing static fields

2015-05-20 Thread Pierre Thibault
This is working well. It is pretty complex to do something that is suppose to be simple. I am not yet able to understand this code. I find Clojure hard to learn. Thank you Keith. Le mercredi 20 mai 2015 21:36:02 UTC-4, Keith Irwin a écrit : > > What about eval? > > user => (eval `(. ~(resolve

Re: One more argument for cyclic dependencies

2015-05-20 Thread Mars0i
Thanks Justin. Exploring the options now, at least for the Student class, which only has to implement an interface. Given the requirements of the standard ways of using the MASON libs, it initially seemed to me that gen-class was my only option. It's clear now that there are other possibilit

Re: Using @ alone

2015-05-20 Thread Adam Morgan
Hi Pierre, If I understand you correctly, you are attempting to crack open a sequence, as ~@ would do in a macro. You are probably looking for apply. For example: (apply + '(1 2 3)) 6 On Wednesday, May 20, 2015 at 6:07:13 PM UTC-6, Pierre Thibault wrote: > > No: > > (type '()) > clojure.lan

Why isn't definterface in the cheatsheet?

2015-05-20 Thread Mars0i
Is there any reason why definterface is missing from the Clojure 1.6 documentation cheatsheets? The same is true of the "other versions with tooltips". Nothing I've read suggests that definterface is deprecated. -- You received this message because you are subscribed to the Google Groups "Clo

Re: Accessing static fields

2015-05-20 Thread Andy Fingerhut
Java interop _with method names known at compile time_ is pretty simple, and is the most common case I have seen. Why do you think it is supposed to be simple to select Java methods based upon the values of variables at run time? Andy On Wed, May 20, 2015 at 7:31 PM, Pierre Thibault wrote: > T

Re: Why isn't definterface in the cheatsheet?

2015-05-20 Thread Andy Fingerhut
The cheat sheet doesn't include everything. Most things in Clojure, yes, but not all. Looking at the log of the last time I generated the latest version of the cheat sheet, it does not include the 172 Vars listed below. You can file an issue if there are any you think especially ought to be adde

Re: Why isn't definterface in the cheatsheet?

2015-05-20 Thread Mars0i
Ah, OK, thanks. I probably depend too mcuh on the cheatsheets. But I'll go ahead and file an issue for definterface; I think it should be there as an alternative to gen-interface. On Wednesday, May 20, 2015 at 10:24:16 PM UTC-5, Andy Fingerhut wrote: > > The cheat sheet doesn't include everyth

Re: Using @ alone

2015-05-20 Thread Pierre Thibault
Hi Adam, I want to play to learn Clojure. It is not so much with a purpose in mind. Yes, apply works well. Le mercredi 20 mai 2015 23:14:43 UTC-4, Adam Morgan a écrit : > > Hi Pierre, > > If I understand you correctly, you are attempting to crack open a > sequence, as ~@ would do in a macro.

Re: Accessing static fields

2015-05-20 Thread Pierre Thibault
I love to program in Python and when you want do something in Python it is usually easy. This makes your imagination powerful. Sad to see it is not the same in Java. Le mercredi 20 mai 2015 23:17:56 UTC-4, Andy Fingerhut a écrit : > > Java interop _with method names known at compile time_ is pre