
20 Apr
2006
20 Apr
'06
10:12 a.m.
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 overflow.
it seems that you just construct huge unevaluated thunk. making things stricter is a whole art, in this case try the following:
writeSTRef b (ev
writeSTRef b $! (ev for :: Int -> IO () -> IO ()
for 0 c = return ()
for n c = c >> for (n-1) c i recommend you to use your `for` instead of your `while` - it's a much faster
and straightforward
--
Best regards,
Bulat mailto:Bulat.Ziganshin@gmail.com