[Haskell-cafe] Re: If the local variable can be changed ...

John Lato jwlato at gmail.com
Wed Mar 10 06:21:55 EST 2010

> From: zaxis <z_axis at 163.com>

> So if the local variable can be changed, then we can use loop, etc. same as
> imperative languages. For example, for (i=0; i<100; i++)  where `i` is a
> local variable in function.

In addition to John Millikin's suggestion, you can also do:

map f [0..99]
  where f :: Int -> a; f = ...


mapM f [0..99]
  where f :: Int -> m a; f = ...

for monadic actions.  Here "f" is the body of the loop.  The loop
bodies must be completely independent, but this is a very useful


More information about the Haskell-Cafe mailing list