13 lines
578 B
TeX
13 lines
578 B
TeX
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
|
|
\vspace{\baselineskip}
|
|
\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}
|
|
\\
|
|
What might happen if we remove the second or the third line? What is a \textbf{partial function} and a \textbf{total function}? |