Skip to content

Commit

Permalink
modify function composition example
Browse files Browse the repository at this point in the history
  • Loading branch information
Greg Yang committed Oct 20, 2015
1 parent b354013 commit a76be91
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions haskell.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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 = 75
foo 5 -- 60

-- fixing precedence
-- Haskell has another operator called `$`. This operator applies a function
Expand Down

0 comments on commit a76be91

Please sign in to comment.