Re: 'while' loop on mutable arrays causes stack overflow

2006-04-20 Thread Gunnar Kedenburg
Hello Bulat, Bulat Ziganshin wrote: > the fastest way to calculate dot product is: > > dot :: STUArray s Int Double -> STUArray s Int Double -> ST s Double > dot x y = do > let (l,r) = bounds x > cycle sum i | sum `seq` i>r = return sum > cycle sum i = do xi

Re[2]: 'while' loop on mutable arrays causes stack overflow

2006-04-20 Thread Bulat Ziganshin
Hello Gunnar, Thursday, April 20, 2006, 7:34:33 PM, you wrote: > Thanks a lot, it works now. I believed that writeSTRef would always > evaluate its arguments because ST is strict, but apparently I was > mistaken :) strict ST monad means that all operations inside it are performed immediately and

Re: 'while' loop on mutable arrays causes stack overflow

2006-04-20 Thread Lemmih
On 4/20/06, Gunnar Kedenburg <[EMAIL PROTECTED]> wrote: > Hello, > > a friend and I were recently experimenting with mutable arrays. We tried > to implement a simple dot product on STUArrays using a 'while' loop. > Unfortunately, every implementation we p

Re: 'while' loop on mutable arrays causes stack overflow

2006-04-20 Thread Gunnar Kedenburg
Hello Bulat, Bulat Ziganshin wrote: > it seems that you just construct huge unevaluated thunk. making things > stricter is a whole art, in this case try the following: > [...] Thanks a lot, it works now. I believed that writeSTRef would always evaluate its arguments because ST is strict, but appa

Re: 'while' loop on mutable arrays causes stack overflow

2006-04-20 Thread Bulat Ziganshin
Hello Gunnar, Thursday, April 20, 2006, 4:29:29 PM, you wrote: > a friend and I were recently experimenting with mutable arrays. We tried > to implement a simple dot product on STUArrays using a 'while' loop. > Unfortunately, every implementation we produced caused a stack

'while' loop on mutable arrays causes stack overflow

2006-04-20 Thread Gunnar Kedenburg
Hello, a friend and I were recently experimenting with mutable arrays. We tried to implement a simple dot product on STUArrays using a 'while' loop. Unfortunately, every implementation we produced caused a stack overflow. Switching to other implementations of 'while' or to IO

Re: Mutable Arrays

2000-05-09 Thread Marc van Dongen
Michael Weber ([EMAIL PROTECTED]) wrote: [...] : $ cvs log ghc/lib/std/PrelArr.lhs : : revision 1.19 : date: 2000/03/14 12:16:00; author: simonmar; state: Exp; lines: +57 -57 : Simplfy the mutable array story: : - rename MutableArray to STArray (and similarly : for all oper

Re: Mutable Arrays

2000-05-09 Thread Michael Weber
On Tue, May 09, 2000 at 11:37:46 +0100, Marc van Dongen wrote: > What does one have to do to use mutable arrays? > An old program won't compile anymore with a very > recent ghc from CVS. I am using GlaExts. $ cvs log ghc/lib/std/PrelArr.lhs revision 1.19 date: 2000/03/14 12:

Mutable Arrays

2000-05-09 Thread Marc van Dongen
Hello again, Sorry for asking again but I can't find the answer in the on line user manual. What does one have to do to use mutable arrays? An old program won't compile anymore with a very recent ghc from CVS. I am using GlaExts. Thanks in advance. Regards, Marc van Dongen --

Mutable Arrays

2000-05-08 Thread Marc van Dongen
Hello all, I wanted to recompile some old programs with the latest ghc from CVS. MutableArray wasn't known any more. I do import GlaExts. What am I missing? Regards, Marc van Dongen -- Marc van Dongen, CS Dept | phone: +353 21 4903578 University College Cork, NUIC | Fax:+353 21 49