Skip to content

Instantly share code, notes, and snippets.

@rikusalminen
rikusalminen / fold_excersizes.hs
Created October 20, 2011 09:03 — forked from pimeys/fold_excersizes.hs
strToInt and StrToDouble
import Data.Char
strToInt :: String -> Int
strToInt ('+':xs) = strToInt xs
strToInt ('-':xs) = - strToInt xs
strToInt xs =
foldl step 0 xs
where
step acc x = acc * 10 + (digitToInt x)
strToInt _ = undefined