haskell-lectures/VL1/content/VL1_case_of.tex
2015-04-21 14:07:42 +02:00

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).