John Harrop writes:
Hi John,
>> Although that doesn't really help, the normal `reduce' doesn't do
>> better.
>>
>> (reduce + (take 100 (iterate inc 1))) ; works
>> (reduce + (take 1000 (iterate inc 1))) ; OutOfMemoryError
>
> Are you sure? I'd expect that with
>
> (def integers (iterat
How about:
(defn limited-reduce [f coll n]
(reduce f (take n coll)))
Rosen
On Sep 18, 10:52 pm, Patrik Fredriksson wrote:
> Hi!
>
> Could someone please help me understand why the following causes a
> java.lang.OutOfMemoryError: Java heap space for large n:s (10
> works fine, 100 do
2009/9/18 ajuc
>
> I was probably wrong - too many classes should throw error about
> permGenSpace (at least in java they do).
>
Yes. A literal (fn) will only create one class. And returning it 100.000
times in a tight loop will create 100.000 instances of this class.
>
> Also for me it works
On Sep 18, 10:46 pm, John Harrop wrote:
> On Fri, Sep 18, 2009 at 4:39 PM, Tassilo Horn wrote:
>
> > Although that doesn't really help, the normal `reduce' doesn't do
> > better.
>
> > (reduce + (take 100 (iterate inc 1))) ; works
> > (reduce + (take 1000 (iterate inc 1))) ; OutOfMemoryE
On Fri, Sep 18, 2009 at 3:52 PM, Patrik Fredriksson wrote:
>
> Hi!
>
> Could someone please help me understand why the following causes a
> java.lang.OutOfMemoryError: Java heap space for large n:s (10
> works fine, 100 does not).
>
> (def integers (iterate inc 1))
>
> (defn limited-reduce
On Fri, Sep 18, 2009 at 4:39 PM, Tassilo Horn wrote:
> Although that doesn't really help, the normal `reduce' doesn't do
> better.
>
> (reduce + (take 100 (iterate inc 1))) ; works
> (reduce + (take 1000 (iterate inc 1))) ; OutOfMemoryError
Are you sure? I'd expect that with
(def integ
It would be kind of nice to have some sort of uniform identifier for
laziness similar to ! for destructive and ? for predicate.
On Sep 18, 5:10 pm, Raoul Duke wrote:
> > Runs (in a nice constant memory) even though yours (which almost
> > appears equivalent) will not!
>
> i am thinking ever more
> Runs (in a nice constant memory) even though yours (which almost
> appears equivalent) will not!
i am thinking ever more that less than stupendously overt syntax for
laziness is too risky cf. Haskell and Clojure.
sincerely.
--~--~-~--~~~---~--~~
You received th
http://www.haskell.org/haskellwiki/Performance
These are the performance tips I was referring to.
(4. General techniques, laziness, space leaks.)
On Sep 18, 5:03 pm, Jonathan Smith wrote:
> Hi!
>
> This is happening because you have integers saved to a global
> variable.
>
> (iterate inc 1) cre
Hi!
This is happening because you have integers saved to a global
variable.
(iterate inc 1) creates an infinite lazy seq.
Def-fing it to a global says 'Hey, i might want this later!' to
Clojure.
This means that as you take numbers from integers;
they get saved in memory rather than being garba
Hi,
On Sep 18, 10:39 pm, Tassilo Horn wrote:
> Patrik Fredriksson writes:
>
> Hi Patrick,
>
>
>
> > Could someone please help me understand why the following causes a
> > java.lang.OutOfMemoryError: Java heap space for large n:s (10
> > works fine, 100 does not).
>
> > (def integers (it
On Sep 18, 10:35 pm, Jarkko Oranen wrote:
> On Sep 18, 10:52 pm, Patrik Fredriksson wrote:
>
>
>
> > Hi!
>
> > Could someone please help me understand why the following causes a
> > java.lang.OutOfMemoryError: Java heap space for large n:s (10
> > works fine, 100 does not).
>
> > (def
Patrik Fredriksson writes:
Hi Patrick,
> Could someone please help me understand why the following causes a
> java.lang.OutOfMemoryError: Java heap space for large n:s (10
> works fine, 100 does not).
>
> (def integers (iterate inc 1))
>
> (defn limited-reduce [fn coll n]
> (loop [c c
I was probably wrong - too many classes should throw error about
permGenSpace (at least in java they do).
Also for me it works for n=100, fails for 1000 (clojurebox
1.0).
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Goog
On Sep 18, 10:52 pm, Patrik Fredriksson wrote:
> Hi!
>
> Could someone please help me understand why the following causes a
> java.lang.OutOfMemoryError: Java heap space for large n:s (10
> works fine, 100 does not).
>
> (def integers (iterate inc 1))
>
> (defn limited-reduce [fn coll n]
I'm beginner myself, but I' think it's because it creates 100 new
classes (for each new anonymous fn).
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@g
Hi!
Could someone please help me understand why the following causes a
java.lang.OutOfMemoryError: Java heap space for large n:s (10
works fine, 100 does not).
(def integers (iterate inc 1))
(defn limited-reduce [fn coll n]
(loop [c coll i n result 0]
(if (zero? i)
result
(rec
17 matches
Mail list logo