haskell-lectures/VL1/content/VL1_pattern_matching.tex

13 lines
562 B
TeX
Raw Normal View History

In haskell we often use \textbf{pattern matching}. That means we define a function multiple times, but e.g. for different values of its input arguments. Let's see:
\pause
\begin{haskellcode}
isZero :: Int -> Bool
isZero 0 = True
isZero x = False
\end{haskellcode}
\vspace{\baselineskip}
So if we pass it 0, we get True. If we do not pass 0, we get False and the value we passed gets basically ignored.
\vspace{\baselineskip}
\\
2015-04-20 13:08:25 +00:00
\pause
What might happen if we remove the second or the third line? What is a \textbf{partial function} and a \textbf{total function}?