summaryrefslogtreecommitdiffhomepage
path: root/haskell.html.markdown
diff options
context:
space:
mode:
Diffstat (limited to 'haskell.html.markdown')
-rw-r--r--haskell.html.markdown19
1 files changed, 10 insertions, 9 deletions
diff --git a/haskell.html.markdown b/haskell.html.markdown
index 6a64442f..936744a0 100644
--- a/haskell.html.markdown
+++ b/haskell.html.markdown
@@ -81,7 +81,7 @@ not False -- True
[5,4..1] -- [5, 4, 3, 2, 1]
-- indexing into a list
-[0..] !! 5 -- 5
+[1..10] !! 3 -- 4
-- You can also have infinite lists in Haskell!
[1..] -- a list of all the natural numbers
@@ -195,11 +195,11 @@ foo 5 -- 15
-- function composition
-- the (.) function chains functions together.
-- For example, here foo is a function that takes a value. It adds 10 to it,
--- multiplies the result of that by 5, and then returns the final value.
-foo = (*5) . (+10)
+-- multiplies the result of that by 4, and then returns the final value.
+foo = (*4) . (+10)
--- (5 + 10) * 5 = 75
-foo 5 -- 75
+-- (5 + 10) * 4 = 60
+foo 5 -- 60
-- fixing precedence
-- Haskell has another operator called `$`. This operator applies a function
@@ -209,14 +209,15 @@ foo 5 -- 75
-- the expression on its right is applied as the parameter to the function on its left.
-- before
-(even (fib 7)) -- false
-
--- after
-even . fib $ 7 -- false
+even (fib 7) -- false
-- equivalently
even $ fib 7 -- false
+-- composing functions
+even . fib $ 7 -- false
+
+
----------------------------------------------------
-- 5. Type signatures
----------------------------------------------------