mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2024-12-23 17:41:41 +00:00
[haskell.html.markdown] Changed explanation for Haskell '$' operator
This commit is contained in:
parent
9fb21f1ce4
commit
2f43da109f
@ -202,10 +202,12 @@ foo = (*5) . (+10)
|
|||||||
foo 5 -- 75
|
foo 5 -- 75
|
||||||
|
|
||||||
-- fixing precedence
|
-- fixing precedence
|
||||||
-- Haskell has another function called `$`. Anything appearing after it will
|
-- Haskell has another operator called `$`. This operator applies a function
|
||||||
-- take precedence over anything that comes before.
|
-- to a given parameter. In contrast to standard function application, which
|
||||||
-- You can use `$` (often in combination with `.`)
|
-- has highest possible priority of 10 and is left-associative, the `$` operator
|
||||||
-- to get rid of a lot of parentheses:
|
-- has priority of 0 and is right-associative. Such a low priority means that
|
||||||
|
-- all other operators on both sides of `$` will be evaluated before applying
|
||||||
|
-- the `$`.
|
||||||
|
|
||||||
-- before
|
-- before
|
||||||
(even (fib 7)) -- false
|
(even (fib 7)) -- false
|
||||||
|
Loading…
Reference in New Issue
Block a user