Syntax in Patterns
Pattern decomposition can also be used in the case
, where
and let
.
mySum list =
case list of
[] -> 0
x : xs -> x + mySum xs
divImod n m
| n < m = (0, n)
| otherwise = (q + 1, r)
where
(q, r) = divImod (n - m) m
firstAndsecond list =
let first : second : rest = list
in (first, second)