Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

An EXPERT PROGRAMMER explains OO

Name: Anonymous 2008-03-19 11:50

Because I know you were all having so much trouble with this difficult concept.

http://theunixgeek.blogspot.com/2007/11/understanding-object-oriented.html

Name: Anonymous 2008-03-21 20:29

>>37
No, the putStrLn . show part transforms the list of numbers to a list of ()'s, printing a bunch of strings as a side effect. The return value is [(),(),(),()]. It's printed because ghci assumes that any non-() value is potentially interesting.
If that's not what you want, make sure that the return value is (), e.g. by using mapM (putStrLn . show) [1..4] >> return (). However, an EXPERT HASKELL PROGRAMMER would use library functions to his advantage and simply write mapM_ print [1..4] or even putStr . unlines . map show $ [1..4].

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List