=
42
"Arthur Dent"
[1, 2, 3]
(42, "fortytwo")
Evaluates to the value itself
(1 + 2) * 3
3.14 * 2 * 17
3^2 + 4^2 == 5^2
Evaluates to the result of the operation
max 23 42
length [1, 2, 3]
triple 3
answer = 42
crew = ["Kirk", "Spock", "McCoy"]
42
is bound to name answer
crew
answer
and crew
can be used in other expressiontriple x = x + x + x
hello name = "Hello " ++ name
x = 1
if x < 2 then "Smaller than two" else "Bigger than 2"
if
expression in a function declaration¶max a b = if a > b then a else b
{.haskell}
seven = 7
triple x = x + x + x
max a b = if a > b then a else b
seven
, triple
, max
)a
, b
, x
)3.141 * 5 * 5
3.141 * 42 * 42
3.141 * 17 * 17
circleArea r = 3.141 * r ^ 2
mean list = totalSum list / count list
count list =
if null list
then 0
else 1 + count (tail list)
totalSum list =
if null list
then 0
else head list + totalSum (tail list)