You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

13 lines
578 B

  1. 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:
  2. \pause
  3. \vspace{\baselineskip}
  4. \begin{haskellcode}
  5. isZero :: Int -> Bool
  6. isZero 0 = True
  7. isZero x = False
  8. \end{haskellcode}
  9. \vspace{\baselineskip}
  10. 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.
  11. \vspace{\baselineskip}
  12. \\
  13. What might happen if we remove the second or the third line? What is a \textbf{partial function} and a \textbf{total function}?