[Haskell-cafe] Re: turning an imperative loop to Haskell

apfelmus apfelmus at quantentunnel.de
Thu Sep 6 09:42:50 EDT 2007

Dougal Stanton wrote:
> To create an infinite list where each f(u) depends on the previous u,
> with a single seed value, use 'iterate':

> main = mapM_ (uncurry (printf "%d %f\n")) (zip [1..50] (iterate f 3))

How about

  main = sequence_ $ zipWith (printf "%d %f\n") [1..50] (iterate f 3)


More information about the Haskell-Cafe mailing list