Re: First program, in case you want to give hints

2010-02-16 Thread alux
;-) It didnt exactly do what I did, it just produced the numers I needed in between, I had to add the filtering. Then I compared the time, and yours is almost 40% quicker. Cool! (First time I saw type hints in Clojure. :) Now the main difference was the call to step. You did it tail call optimis

Re: First program, in case you want to give hints

2010-02-16 Thread Sean Devlin
Interesting... could you add a few test cases? I want to make sure my implementation does what you expect. Thanks, Sean On Feb 16, 11:18 am, alux wrote: > I'm curious, but as you told me, I pasted my solution (with a lazy > stream), as annotation of my former program. > > http://paste.lisp.org

Re: First program, in case you want to give hints

2010-02-16 Thread alux
I'm curious, but as you told me, I pasted my solution (with a lazy stream), as annotation of my former program. http://paste.lisp.org/+21BR/1 So, now I'll have a look at yours. Thanks, and read you sn. alux On 16 Feb., 14:32, Sean Devlin wrote: > Alux, > This is good progress, keep up the

Re: First program, in case you want to give hints

2010-02-16 Thread Sean Devlin
Alux, This is good progress, keep up the good work. Here's my implementation w/Jarkko's suggestions built in. Take a look at this AFTER you complete your next iteration :) http://gist.github.com/305521 I've changed the following * Imported java.math.BigInteger * Used the instance? predicate to

Re: First program, in case you want to give hints

2010-02-16 Thread Jarkko Oranen
On Feb 16, 12:26 pm, alux wrote: > Hello, > > the current state of Conway's Prime Machine is athttp://paste.lisp.org/+21BR Instead of using a quoted list, a vector is more idiomatic in Clojure. > > I'l go on learning. The next state should be seperation of print and > produce. Currently (conwa

Re: First program, in case you want to give hints

2010-02-16 Thread alux
Hello, the current state of Conway's Prime Machine is at http://paste.lisp.org/+21BR I'l go on learning. The next state should be seperation of print and produce. Currently (conway-pm) doesnt return stuff. I dont know if Clojure can produce infinite lists, like Haskell, and print the items as the

Re: First program, in case you want to give hints

2010-02-14 Thread Johnny Kwan
On Feb 14, 2010, at 8:58 AM, Laurent PETIT wrote: > 2010/2/14 alux : >> Hello Sean, >> >> thank you for the answer. >> >> I used letfn not for recursive swearing, but for the localness. I >> thought the functions to be so special, >> nobody else will use it, so I put it into conway-PM. Is there

Re: First program, in case you want to give hints

2010-02-14 Thread Laurent PETIT
2010/2/14 alux : > Hello Sean, > > thank you for the answer. > > I used letfn not for recursive swearing, but for the localness. I > thought the functions to be so special, > nobody else will use it, so I put it into conway-PM. Is there a non > recursive let for functions? Hello, in this case, yo

Re: First program, in case you want to give hints

2010-02-14 Thread alux
Hello Sean, thank you for the answer. I used letfn not for recursive swearing, but for the localness. I thought the functions to be so special, nobody else will use it, so I put it into conway-PM. Is there a non recursive let for functions? Thanks for the hint about Lisppaste, didnt know that.

Re: First program, in case you want to give hints

2010-02-13 Thread Sean Devlin
Alux, Welcome to Clojrue! Thanks for posting this example. At first glance I would combine power-of-two? and what-power-of-2 into one fn. Also, I would change the order you wrote the method calls in to favor the .method style (defn power-of-2 "Returns log_2(n) iff n is an exact pwoer of 2. n

First program, in case you want to give hints

2010-02-13 Thread alux
Hi, I just finished my first (very small) Clojure program. I come from Java, so it will be everything but idiomatic Clojure, so I post it here and you may give as much criticism as you want. I'm here to learn. It implements JHConway prime machine. The program does not want to be a quick prime gen