diff options
author | Geoff Liu <cangming.liu@gmail.com> | 2015-03-27 10:48:10 -0600 |
---|---|---|
committer | Geoff Liu <cangming.liu@gmail.com> | 2015-03-27 10:48:10 -0600 |
commit | 1f49ae9306cb9ca933827b43d327c85598d58907 (patch) | |
tree | f6ff276407b99aea062b136b9f81ee0238cc3cd8 /haskell.html.markdown | |
parent | bc7fd77654133c3fe8e6574db8e0ed72a50cd0b2 (diff) | |
parent | e8a1ee8912d1c9bb0145c2afbdc530463fc612b7 (diff) |
Merge pull request #1006 from nero-luci/master
Update haskell.html.markdown. Wrong explanation about '$' operator
Diffstat (limited to 'haskell.html.markdown')
-rw-r--r-- | haskell.html.markdown | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/haskell.html.markdown b/haskell.html.markdown index 2f807c5f..f28fcfe7 100644 --- a/haskell.html.markdown +++ b/haskell.html.markdown @@ -202,19 +202,20 @@ foo = (*5) . (+10) foo 5 -- 75 -- fixing precedence --- Haskell has another function called `$`. This changes the precedence --- so that everything to the left of it gets computed first and then applied --- to everything on the right. You can use `$` (often in combination with `.`) --- to get rid of a lot of parentheses: +-- Haskell has another operator called `$`. This operator applies a function +-- to a given parameter. In contrast to standard function application, which +-- has highest possible priority of 10 and is left-associative, the `$` operator +-- has priority of 0 and is right-associative. Such a low priority means that +-- the expression on its right is applied as the parameter to the function on its left. -- before -(even (fib 7)) -- true +(even (fib 7)) -- false -- after -even . fib $ 7 -- true +even . fib $ 7 -- false -- equivalently -even $ fib 7 -- true +even $ fib 7 -- false ---------------------------------------------------- -- 5. Type signatures |