diff --git a/VL1/VL1_document_structure.tex b/VL1/VL1_document_structure.tex index d29f252..3e4e161 100644 --- a/VL1/VL1_document_structure.tex +++ b/VL1/VL1_document_structure.tex @@ -64,11 +64,15 @@ \subsubsection{Pattern matching} -\slide{./content/VL1_functions_and_control_structures2.tex} +\slide{./content/VL1_pattern_matching.tex} + +\subsubsection{Case... of} + +\slide{./content/VL1_case_of.tex} \subsubsection{Guards and recursion} -\slide{./content/VL1_functions_and_control_structures3.tex} +\slide{./content/VL1_guards_and_recursion.tex} \subsection{Lists} diff --git a/VL1/content/VL1_case_of.tex b/VL1/content/VL1_case_of.tex new file mode 100644 index 0000000..42012d6 --- /dev/null +++ b/VL1/content/VL1_case_of.tex @@ -0,0 +1,10 @@ +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. \ No newline at end of file diff --git a/VL1/content/VL1_functions_and_control_structures3.tex b/VL1/content/VL1_guards_and_recursion.tex similarity index 100% rename from VL1/content/VL1_functions_and_control_structures3.tex rename to VL1/content/VL1_guards_and_recursion.tex diff --git a/VL1/content/VL1_functions_and_control_structures2.tex b/VL1/content/VL1_pattern_matching.tex similarity index 100% rename from VL1/content/VL1_functions_and_control_structures2.tex rename to VL1/content/VL1_pattern_matching.tex