diff options
author | Geoff Liu <g@geoffliu.me> | 2015-04-17 14:06:47 -0400 |
---|---|---|
committer | Geoff Liu <g@geoffliu.me> | 2015-04-17 14:06:47 -0400 |
commit | 49e8dd42636199f19d250bc6b169764f5ebe0ed7 (patch) | |
tree | 4a91f68d8c75720eb8c1cf288fcbeba0f841e62c /haskell.html.markdown | |
parent | 61510ee92caaca9c841da6e40c8e1d680d1b7e34 (diff) | |
parent | b44aded453d94d5a196356f3c05c678d6ec9323c (diff) |
Merge remote-tracking branch 'upstream/master'
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 |