Re: Help: Stack-overflow and tail-recursive functions

2003-06-20 Thread Koji Nakahara
0MB). Interestingly, on GHCi, the program shows the elements which are constructed from the first row of the matrix, "rests awhile" and then stack overflows (n >= 600) or continues fine (n <= 500). With the improved definition of rmat I wrote in my last mail (Subject: listAr

RE: Help: Stack-overflow and tail-recursive functions

2003-06-20 Thread Hal Daume
> GHCi didn't have any problem even with the original code. mine didn't either, until I increased the "200" to around "1500"...it's probably OS/memory specific. ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haske

listArray and stack overflow (Re: Help: Stack-overflow and tail-recursive functions)

2003-06-19 Thread Koji Nakahara
I did some experiments and now suspect that the culprit is the infinite list. When I replace rmat with > rmat n = listArray ((1,1),(n,n)) [1..] -- no longer random , > print (m ! (300, 300)) where m = rmat 800 fails again. However, if I use a finite list as the second argument of listArray: > rm

Re: Help: Stack-overflow and tail-recursive functions

2003-06-19 Thread oleg
It seems the problem is indeed in rmat: > rmat n =listArray ((1,1),(n,n)) $ map ct (randoms (mkStdGen 1) ::[Bool]) > where ct True = Unknown > ct False = Dead To be more precise, the problem is in randoms. If you replace rmat with the following rmat n =

RE: Help: Stack-overflow and tail-recursive functions

2003-06-19 Thread Hal Daume
e III | [EMAIL PROTECTED] "Arrest this man, he talks in maths." | www.isi.edu/~hdaume > -Original Message- > From: Koji Nakahara [mailto:[EMAIL PROTECTED] > Sent: Wednesday, June 18, 2003 7:41 PM > To: Hal Daume; [EMAIL PROTECTED] > Subject: Re:

Re: Help: Stack-overflow and tail-recursive functions

2003-06-18 Thread Koji Nakahara
On Wed, 18 Jun 2003 17:36:28 -0700 "Hal Daume" <[EMAIL PROTECTED]> wrote: > Note that there is essentially no difference between f1 and f2. When > you $! in f2, all it does is ensure that the argument isn't undefined. > It doesn't evaluate any of the list. Try $!! from the DeepSeq module or > wr

RE: Help: Stack-overflow and tail-recursive functions

2003-06-18 Thread Hal Daume
Note that there is essentially no difference between f1 and f2. When you $! in f2, all it does is ensure that the argument isn't undefined. It doesn't evaluate any of the list. Try $!! from the DeepSeq module or write your own list-forcing function. For me, the following works: f1 0 l = l f1 n