From b0840f22e53f6a820b11ba538fb3a9b926fb9b29 Mon Sep 17 00:00:00 2001 From: Louis Pilfold Date: Tue, 12 Dec 2023 15:29:01 +0000 Subject: More lessons --- lessons/src/lesson025_list_patterns/text.html | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 lessons/src/lesson025_list_patterns/text.html (limited to 'lessons/src/lesson025_list_patterns/text.html') diff --git a/lessons/src/lesson025_list_patterns/text.html b/lessons/src/lesson025_list_patterns/text.html new file mode 100644 index 0000000..de55eef --- /dev/null +++ b/lessons/src/lesson025_list_patterns/text.html @@ -0,0 +1,15 @@ +

+ Lists and the values they contain can be pattern matched on in case + expressions. +

+

+ List patterns match on specific lengths of lists. The pattern [] + matches an empty list, and the pattern [_] matches a list with + one element. They will not match on lists with other lengths. +

+

+ The spread pattern .. can be used to match the rest of the list. + The pattern [1, ..] matches any list that starts with + 1. The pattern [_, _, ..] matches any list that has + at least two elements. +

-- cgit v1.2.3