10 lines
328 B
TeX
10 lines
328 B
TeX
We can also pattern match on the result of a real expression, not just the input. For that, we write:
|
|
|
|
\begin{haskellcode}
|
|
f :: Int -> Bool
|
|
f x = case x - 2 of
|
|
2 -> True
|
|
5 -> True
|
|
y -> False
|
|
\end{haskellcode}
|
|
This allows more powerful pattern matching, especially when we define our own data structures (not this lecture). |