
Max Voit schreef op 5-2-2015 om 13:35:
On Thu, 05 Feb 2015 13:25:16 +0100 Roelof Wobben
wrote: Another question : how can I display the array ?
putStrln works only for strings, Yep, so you need to convert it to a string and putStrLn that. Kindly enough typing ":i []" into ghci tells you, that lists have an instance for "show".
Anonther option would be to convert every single list element to a string and putStrLn that. "map" comes in handy here (or mapM_ if you directly want to use print instead of putStrLn . show).
best, Max _______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners
Thanks that part worked fine. One part I cannot figure out is how to make this : -- | Main entry point to the application. module Main where -- | convert a number to a array in pieces where a negative number will be a empty array. toDigits :: Integer -> [Integer] toDigits n | n < 0 = [] | otherwise = n `mod` 10 : [] -- | The main entry point. main :: IO () main = do print $ toDigits 123 Now it showing only [1] or [23] I have to find out how I can do something like this toDigits 23 [1] But I cannot do this that way because it has to be Integer -> [Integer] Who has a tip for me ? Roelof