modify function composition example

This commit is contained in:
Greg Yang 2015-10-20 12:05:16 -07:00
parent b354013dc9
commit a76be91a2d

View File

@ -195,11 +195,11 @@ foo 5 -- 15
-- function composition -- function composition
-- the (.) function chains functions together. -- the (.) function chains functions together.
-- For example, here foo is a function that takes a value. It adds 10 to it, -- 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. -- multiplies the result of that by 4, and then returns the final value.
foo = (*5) . (+10) foo = (*4) . (+10)
-- (5 + 10) * 5 = 75 -- (5 + 10) * 4 = 75
foo 5 -- 75 foo 5 -- 60
-- fixing precedence -- fixing precedence
-- Haskell has another operator called `$`. This operator applies a function -- Haskell has another operator called `$`. This operator applies a function