אביעד

On 10 February 2010 19:54, Aviad Reich <avi....@gmail.com> 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)
>
> This indeed is a great community, so let me try another (related) question.
>
> Comparing my solution with an identical one - but without memoization
> produces a faster result.
> I understand that caching all the results has some overhead, but how come
> it isn't balanced with the speedup from the cached values?
>
> Again,
> Thanks!
>
> Aviad
>
>
> On 10 February 2010 19:40, Greg <g...@kinostudios.com> wrote:
>
>> 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 involve a
>> lot of memory.
>>
>> - Greg
>>
>> On Feb 10, 2010, at 10:13 AM, Aviad Reich wrote:
>>
>> 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 <iko...@gmail.com> wrote:
>>
>>> (Disclaimer: never tried myself)
>>> http://hausheer.osola.com/docs/5
>>>
>>> 2010/2/10 Aviad R <avi....@gmail.com>
>>>
>>> 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 those
>>>> wanting to solve it in the future).
>>>>
>>>> The problem and my code are in https://pastee.org/hj3sh
>>>>
>>>> here is the problem:
>>>> I am trying to produce a map of one O(million) key-value pairs using a
>>>> recursive function.
>>>>
>>>> I can produce a map of the first 100000 numbers in ~1300 msecs, with
>>>> 217211 keys.
>>>> However, for 150000 and up, I get java.lang.OutOfMemoryError: Java
>>>> heap space.
>>>>
>>>> so, I assume my code is ok on efficiency, but the recursion is too
>>>> deep.
>>>>
>>>> am I right? can anyone suggest a way to overcome this problem?
>>>> any additional tips and thoughts on the code would be of great help to
>>>> me, as I am making my first steps in clojure.
>>>>
>>>> Thank you,
>>>> Aviad
>>>>
>>>> --
>>>> 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 - please be patient with
>>>> your first post.
>>>> To unsubscribe from this group, send email to
>>>> clojure+unsubscr...@googlegroups.com<clojure%2bunsubscr...@googlegroups.com>
>>>> For more options, visit this group at
>>>> http://groups.google.com/group/clojure?hl=en
>>>
>>>
>>>
>>>
>>> --
>>> Communication is essential. So we need decent tools when communication is
>>> lacking, when language capability is hard to acquire...
>>>
>>> - http://esperanto.net  - http://esperanto-jongeren.nl
>>>
>>> Linux-user #496644 (http://counter.li.org) - first touch of linux in
>>> 2004
>>>
>>> --
>>> 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 - please be patient with
>>> your first post.
>>> To unsubscribe from this group, send email to
>>> clojure+unsubscr...@googlegroups.com<clojure%2bunsubscr...@googlegroups.com>
>>> For more options, visit this group at
>>> http://groups.google.com/group/clojure?hl=en
>>>
>>
>>
>> --
>> 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 - please be patient with
>> your first post.
>> To unsubscribe from this group, send email to
>> clojure+unsubscr...@googlegroups.com
>> For more options, visit this group at
>> http://groups.google.com/group/clojure?hl=en
>>
>>
>>  --
>> 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 - please be patient with
>> your first post.
>> To unsubscribe from this group, send email to
>> clojure+unsubscr...@googlegroups.com<clojure%2bunsubscr...@googlegroups.com>
>> For more options, visit this group at
>> http://groups.google.com/group/clojure?hl=en
>>
>
>

-- 
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 - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to