Hello minh,

Monday, May 8, 2006, 12:28:35 PM, you wrote:

> acc1 ints = foldr (+) 0 ints

foldl?

> ----------------------------------------------------------------------

> acc2 ints = execState (mapM add2 ints) 0

> add2 :: Int -> State Int ()
> add2 i = do
>      acc <- get
>      put (acc + i)

put $! (acc+i)

> ----------------------------------------------------------------------

> acc3 ints = runST (acc3' ints :: ST s Int)

> acc3' ints = do
>      accRef <- newSTRef 0
>      mapM (add3 accRef) ints
>      acc <- readSTRef accRef
>      return acc

> add3 accRef i = do
>      modifySTRef accRef (+ i)

use readref/writeref and $!

-- 
Best regards,
 Bulat                            mailto:[EMAIL PROTECTED]

_______________________________________________
Haskell mailing list
Haskell@haskell.org
http://www.haskell.org/mailman/listinfo/haskell

Reply via email to