Thursday, April 02, 2009

Write Yourself a Scheme - 1

Here are the solutions to ``Write Yourself a Scheme in 48 Hours'', "First steps: Compiling and running".

ex1.
main = do args <- getArgs
    putStrLn ("Hello, " ++ args !! 0 ++ ", " ++ args !! 1)

ex2.
main = do line <- getLine
    putStrLn("Hello, " ++ line)

ex3.
str2int s = read s :: Int
str2flt s = read s :: Float

main = do args <- getArgs
    putStrLn (show (str2int(args !! 0) + str2int(args !! 1)))

Labels: ,

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home