Author | Message |
---|---|
rabbott
Posts: 1649
|
Posted 13:24 Oct 24, 2016 |
Haskell like most mathematical and programming notations allows you to leave out parentheses when using operators. For example > 4 - 3 - 1 The implicit parenthesizing is > (4 - 3) - 1 Not > 4 - (3 - 1) It's important for you to know how arguments are combined by operators. So I may ask you about that. For example, if you write f . g . h x what are the implicit parentheses? In this example, what must be the case for this, as written, to be syntactically valid? |
rabbott
Posts: 1649
|
Posted 21:24 Oct 24, 2016 |
Here is a table of precedence and associativity. Function application may be considered precedence 10 and left associative: Note that
+--------+----------------------+-----------------------+-------------------+
| Prec- | Left associative | Non-associative | Right associative |
| edence | operators | operators | operators |
+--------+----------------------+-----------------------+-------------------+
| 9 | !! | | . |
| 8 | | | ^, ^^, ** |
| 7 | *, /, `div`, | | |
| | `mod`, `rem`, `quot` | | |
| 6 | +, - | | |
| 5 | | | :, ++ |
| 4 | | ==, /=, <, <=, >, >=, | |
| | | `elem`, `notElem` | |
| 3 | | | && |
| 2 | | | || |
| 1 | >>, >>= | | |
| 0 | | | $, $!, `seq` |
+--------+----------------------+-----------------------+-------------------+
Last edited by rabbott at
21:25 Oct 24, 2016.
|