Re: [Haskell-cafe] loop problem

Stuart A. Kurtz schreef op 10-5-2014 18:17:
Dear Roelof,
I took a quick look at the course -- it wasn't immediately evident to me where you are in it. It looks pretty good, although more examples/exercise are always welcome.
It occurred to me, though, if you're going to write it so it looks like C, you'd might as well take advantage of Text.Printf:
import Control.Monad import Text.Printf
loop :: Int -> IO () loop n = when (n <= 100) $ do printf "%d %d\n" n (n^2) loop $ n+1
main :: IO () main = loop 1
Peace,
Stu
Sorry that I did not make that clear. So in your oponion this could be a good way to learn haskell very good. I get the feeling on your remarks that im not really to do things the haskell way and that is what im looking for. I have looked at the book http://learnyouahaskell.com/chapters but I miss there exercises What do you think about this one : http://www.umiacs.umd.edu/~hal/docs/daume02yaht.pdf Roelof

On Saturday, May 10, 2014, Roelof Wobben
Stuart A. Kurtz schreef op 10-5-2014 18:17:
Dear Roelof,
I took a quick look at the course -- it wasn't immediately evident to me where you are in it. It looks pretty good, although more examples/exercise are always welcome.
It occurred to me, though, if you're going to write it so it looks like C, you'd might as well take advantage of Text.Printf:
import Control.Monad import Text.Printf
loop :: Int -> IO () loop n = when (n <= 100) $ do printf "%d %d\n" n (n^2) loop $ n+1
main :: IO () main = loop 1
Peace,
Stu
Sorry that I did not make that clear. So in your oponion this could be a good way to learn haskell very good.
I get the feeling on your remarks that im not really to do things the haskell way and that is what im looking for. I have looked at the book http://learnyouahaskell.com/chapters but I miss there exercises
What do you think about this one : http://www.umiacs.umd.edu/~ hal/docs/daume02yaht.pdf
http://exercism.io/ has a lot of Haskell exercises and community code review is part of the site so you won't have to ask for help elsewhere. -bob
participants (2)
-
Bob Ippolito
-
Roelof Wobben