Learning Haskell one step at at time
1. -- These is single line comment in haskell
2. -{
This is multiline comment
-}
- Emphasis is on the "functional" view that the purpose of an expression is to return a value
- looping is handled by recursion
- A switch concept is handled with "guards and condiitons"
syntax: if condition then expression1 else expression2
:{
countDown i
| i == 0 = "Take Off!"
| otherwise = show(i) ++ " "++ countDown(i-1) -- ++ is string concat
:}
countDown 10 --calling the function
Output:
10 9 8 7 6 5 4 3 2 1 Take Off