Juan Jose Garcia Ripoll writes:
> I am concerned with the following
> stupid piece of code that eats a lot of memory and takes an incredible
> amount of time to produce some output. I hope somebody will help me in
> finding what I am doing wrong.
>
> Juanjo
>
> ---
> module Main where
>
> import Array
>
> produce :: Int -> Double -> Array Int Double
> produce n x = array (1,n) [(i,x) | i <- [1..n]]
... etc.
OK, Hans Aberg whose talents are so remarkable that he
interpolates between abstract categories and Heap profilers,
suggests the latter...
Kill me, I don't see any reason in this code which requires
really the usage of arrays. Can't you do all this incrementally
with lists, if you construct and consume the arrays in order?
What is this program doing, what kind of scalar product is
that? I mean, what is your *real* problem, your example is
of course artificial.
Anyway, if you ask about strictness annotations... I must say
that until today I managed to gain a little time to have some extra
beers thanks to the laziness rather than to strictness. Then of
course foldl is a little delicate...
Hans writes:
> The Heap Profiler is very slow and consumes a lot of memory, so
> try it only on small values.
When I tried (Hugs, +h4M, interactively, just show, no print)
with 10000, it bombs on control stack overflow.
May the Force be with you (but Delay first...)
Jerzy Karczmarczuk
Caen, France.