This gist and a Functional Society Gist to talk about Calculator homework, so people can share links and help each other to get the homework right and make questions, get you question answered and so on and on...
We need code a simple calculator in Scala and Haskell:
Calculator, basic operations: +, -, /, * (Remember State and Side Effects are not desired)
It`s also possible with Higher Order Functions...
Search for: "Higher Order Functions in Order" => http://learnyouahaskell.com/higher-order-functions
applyTwice :: (a -> a) -> a -> a
applyTwice f x = f (f x)
ghci> applyTwice (++ " HAHA") "HEY"
"HEY HAHA HAHA"
Back to the + here is another sample using Higher Order Functions:
ghci> zipWith' (+) [4,2,5,6] [2,6,2,3]
[6,8,7,9]
Cheers,
Diego Pacheco