You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
668 B
25 lines
668 B
7 years ago
|
# Chapter Exercises
|
||
|
# Parenthesization
|
||
|
1. `(2 + (2 * 3)) - 1`
|
||
|
2. `(^) 10 (1 + 1)`
|
||
|
3. `((2 ^ 2) * (4 ^ 5)) + 1`
|
||
|
|
||
|
# Equivalent expressions
|
||
|
1. Equivalent.
|
||
|
2. Equivalent.
|
||
|
3. Different. `(-) 37 400` is equal to `37 - 400`
|
||
|
4. Different. Integer division versus real division.
|
||
|
5. Different. Multiplication has higher precedence.
|
||
|
|
||
|
# More fun with functions
|
||
|
In the REPL:
|
||
|
|
||
|
`let z = 7; x = y ^ 2; waxOn = x * 5; y = z + 8`
|
||
|
|
||
|
1. `waxOn` is a number equal to `1125`. So it would be as if you replace `waxOn` by `1125`.
|
||
|
2. /
|
||
|
3. This will return `1125 * 3` or `3375`
|
||
|
4. see src/chapter.hs
|
||
|
5. see src/chapter.hs
|
||
|
6. see src/chapter.hs
|
||
|
7. waxOff is basically an for the triple function.
|