[Haskell-cafe] Re: foreach
Henning Thielemann
lemming at henning-thielemann.de
Wed Sep 13 07:37:01 EDT 2006
On Wed, 13 Sep 2006, Bulat Ziganshin wrote:
> Wednesday, September 13, 2006, 1:12:35 PM, you wrote:
>
> > Adding sugar or using Template Haskell for such a simple task is a bit
> > unreasonable. I think Tim should use mapM a little bit and then he will
> > probably need no longer a special syntax.
>
> i disagree. lack of good syntax makes imperative programming in
> Haskell less convenient. i want to have such syntax in order to make
> Haskell great imperative language:
>
> sum <- new 0
> arr <- new Array[1..3]
> for i in [1..3] do
> sum += i
> arr[i] := sum
> for i in [1..3] while arr[i]<2 do
> print arr[i]
let arr = scanl1 (+) [1..3]
in mapM_ print (takeWhile (<2) arr)
More information about the Haskell-Cafe
mailing list