From db789c6643b22c77b1ccaf4ca1feb3c9624ad96e Mon Sep 17 00:00:00 2001 From: Julian Ospald Date: Tue, 21 Apr 2015 18:47:51 +0200 Subject: [PATCH] Add case...of slide, rename slides --- VL1/VL1_document_structure.tex | 8 ++++++-- VL1/content/VL1_case_of.tex | 10 ++++++++++ ...ol_structures3.tex => VL1_guards_and_recursion.tex} | 0 ...ontrol_structures2.tex => VL1_pattern_matching.tex} | 0 4 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 VL1/content/VL1_case_of.tex rename VL1/content/{VL1_functions_and_control_structures3.tex => VL1_guards_and_recursion.tex} (100%) rename VL1/content/{VL1_functions_and_control_structures2.tex => VL1_pattern_matching.tex} (100%) 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