Re: newbie encountering java.lang.OutOfMemoryError: Java heap space

2010-02-10 Thread Aviad Reich
Again, your input was incredibly beneficial for me. William: Thank you for your comments. As i wrote, eventually I came up with a different solution altogether. To answer your question concerning the previous code: my initial idea was that since (although unproven) all the different sequences fin

Re: newbie encountering java.lang.OutOfMemoryError: Java heap space

2010-02-10 Thread Will Hidden
Looking at your post I notice some things that strike me as 'odd'. The use of (def) in a form that is not a top most form. From my experience this leads to trouble in the best of times. I think a better way would be to close over your known-map with a closure. While I don't have high hopes that c

Re: newbie encountering java.lang.OutOfMemoryError: Java heap space

2010-02-10 Thread Brenton
Aviad, You don't get a speedup because you are never calling the memoized function with the same arguments. In your code, n is different each time. memoize basically creates a map of arguments to results. When you call the function with args that it has seen before it bypasses actually calling th

Re: newbie encountering java.lang.OutOfMemoryError: Java heap space

2010-02-10 Thread Aviad Reich
אביעד On 10 February 2010 19:54, Aviad Reich wrote: > Thank you all! > > your advice were indeed very helpful! > > I eventually solved it using memoization. and indeed keeping only 3 values > in memory. > (http://clojure-euler.wikispaces.com/Problem+014 - lxmonk, if you're > interested) > > Thi

Re: newbie encountering java.lang.OutOfMemoryError: Java heap space

2010-02-10 Thread Aviad Reich
Thank you all! your advice were indeed very helpful! I eventually solved it using memoization. and indeed keeping only (http://clojure-euler.wikispaces.com/Problem+014 - lxmonk if you're interested) This indeed is a great community, so let me try another (related) question. Comparing my solutio

Re: newbie encountering java.lang.OutOfMemoryError: Java heap space

2010-02-10 Thread Greg
Hi Aviad, Disclaimer: I haven't read the book, nor do I know Clojure very well. However, based on your question (which I did read) and Brenton's hint, it seems to me like the solution will involve a lazy sequence, which is a frequent tool to use whenever you're dealing with a problems that invo

Re: newbie encountering java.lang.OutOfMemoryError: Java heap space

2010-02-10 Thread Brenton
Aviad, Welcome to Clojure. I don't want to tell you how to solve it. That's all part of the fun. But my hint to you would be that you don't need to keep all 1 million lists in memory. In fact, you should be able to solve this problem by only keeping three numbers in memory at any one time: The nu

Re: newbie encountering java.lang.OutOfMemoryError: Java heap space

2010-02-10 Thread Aviad Reich
thank you. I have "-server" and "-Xmx1024m" set in my 'swank-clojure-extra-vm-args, but the problem remains. Aviad On 10 February 2010 15:57, Joop Kiefte wrote: > (Disclaimer: never tried myself) > http://hausheer.osola.com/docs/5 > > 2010/2/10 Aviad R > > Hi all. >> >> I'm trying to learn c

Re: newbie encountering java.lang.OutOfMemoryError: Java heap space

2010-02-10 Thread Joop Kiefte
(Disclaimer: never tried myself) http://hausheer.osola.com/docs/5 2010/2/10 Aviad R > Hi all. > > I'm trying to learn clojure with the excellent "Programming Clojure" > and projecteuler.net. I am encountering the java heap space error, and > can't find a workaround, nor a smarter way to write my

newbie encountering java.lang.OutOfMemoryError: Java heap space

2010-02-10 Thread Aviad R
Hi all. I'm trying to learn clojure with the excellent "Programming Clojure" and projecteuler.net. I am encountering the java heap space error, and can't find a workaround, nor a smarter way to write my code (which I am certain exist). Trying to solve Problem 14 (some spoilers might be ahead, for