Quentin Le Guennec schreef op 5-2-2015 om 14:34:
Hey,

I read your mail on haskell-cafe mailing list. What is CIS course excatly? Could you send me a link to the exercises? Thanks.

2015-02-05 8:48 GMT+01:00 Roelof Wobben <r.wobben@home.nl>:
Hello,

I have to do this :

Exercise 1 We need to first find the digits of a number. Define the
functions
toDigits :: Integer -> [Integer]
toDigitsRev :: Integer -> [Integer]
toDigits should convert positive Integers to a list of digits. (For 0 or
negative inputs, toDigits should return the empty list.) toDigitsRev
should do the same, but with the digits reversed.
Example: toDigits 1234 == [1,2,3,4]
Example: toDigitsRev 1234 == [4,3,2,1]
Example: toDigits 0 == []
Example: toDigits (-17) == []


I have this so far :

-- | 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/10 : []

-- | Main entry point to the application.
module Main where

-- | The main entry point.
main :: IO ()
main = do
    toDigits 123

but now I see this error message :

src/Main.hs@5:3-5:4
parse error on input |

This is not homework because I do this as a self-study.

Roelof








_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe




--
Quentin Le Guennec

Here you can find the answer  : http://www.seas.upenn.edu/~cis194/spring13/index.html

Roelof