Higher precedence is applied first. Scale is 0-9.
Prelude> :info (^)
(^) :: (Num a, Integral b) => a -> b -> a -- Defined in ‘GHC.Real’
infixr 8 ^
Left associative
2 * 3 * 4
-- is evaluated as if it was
(2 * 3) * 4
Right associative
Prelude> 2 ^ 3 ^ 4
2417851639229258349412352
Prelude> 2 ^ (3 ^ 4)
2417851639229258349412352
Prelude> (2 ^ 3) ^ 4
4096
fix mistakes
let area x = 3. 14 * (x * x)
let area x = 3.14 * (x * x)
let double x = b * 2
let double x = x * 2
link:ch02_2.6_1.hs[role=include]
Prelude> :l ch02_2.6_1.hs
[1 of 1] Compiling Main ( ch02_2.6_1.hs, interpreted )
ch02_2.6_1.hs:2:4: parse error on input ‘=’
Failed, modules loaded: none.
-- fixed
x = 7
y = 10
f = x + y
let x = 5 in x
-- 5
let x = 5 in x * x
-- 25
let x = 5; y = 6 in x * y
-- 30
let x = 3; y = 1000 in x + 3
-- 6
let
rewritten to where
f1 = x
where x = 5
f2 = x * x
where x = 5
f3 = x * y
where x = 5
y = 6
f4 = x + 3
where x = 3
y = 1000
-
2 + 2 * 3 - 1
==2 + (2 * 3) - 1
-
(^) 10 $ 1 + 1
==(^) 10 (1 + 1)
-
2 ^ 2 * 4 ^ 5 + 1
==( (2 ^ 2) * (4 ^ 5) ) + 1
-
1 + 1 == 2
-
10 ^ 2 == 10 + 9 * 10
-
400 - 37 /= (-) 37 400
-
100 `div` 3 /= 100 / 3
-
2 * 5 + 18 /= 2 * (5 + 18)
z = 7
x = y ^ 2
waxOn = x * 5
y = z + 8
to REPL
let z = 7
let y = z + 8
let x = y ^ 2
let waxOn = x * 5
waxOn == 1125
-
results of
10 + waxOn -- 1135 (+10) waxOn -- 1135 (-) 15 waxOn -- -1110 (-) waxOn 15 -- 1110
-
triple
let triple x = x * 3 triple waxOn -- 3375
-
where waxOn
link:ch02_2.12_2.hs[role=include]
-
rest
link:ch02_2.12_3.hs[role=include]
waxOff
istriple
waxOff waxOn
istriple waxOn