
21 May
2009
21 May
'09
3:52 p.m.
Jochem,
rationals n = (putStr . unlines . map show) (take n (nub [x % y | y <- [1..], x <- [1..y], x < y]))
rationals n :: Integer -> [Ratio]
I meant "Integer -> String" obviously.
Er... what about rationals :: Int -> IO () ? ;-) To the original poster: next time, just leave the function definition without the signature and query GHCi for the correct type: Prelude> :m + List Prelude List> :m + Ratio Prelude List Ratio> let rationals n = (putStr . unlines . map show) \ (take n (nub [x % y | y <- [1..], x <- [1..y], x < y])) Prelude List Ratio> :t rationals rationals :: Int -> IO () Cheers, Stefan