From 4efb34bd728732101432843ed0bfbeb971272287 Mon Sep 17 00:00:00 2001 From: Louis Pilfold Date: Thu, 21 Dec 2023 14:03:41 +0000 Subject: Add chapters --- lessons/src/lesson025_list_patterns/code.gleam | 17 ----------------- lessons/src/lesson025_list_patterns/text.html | 15 --------------- 2 files changed, 32 deletions(-) delete mode 100644 lessons/src/lesson025_list_patterns/code.gleam delete mode 100644 lessons/src/lesson025_list_patterns/text.html (limited to 'lessons/src/lesson025_list_patterns') diff --git a/lessons/src/lesson025_list_patterns/code.gleam b/lessons/src/lesson025_list_patterns/code.gleam deleted file mode 100644 index a5619aa..0000000 --- a/lessons/src/lesson025_list_patterns/code.gleam +++ /dev/null @@ -1,17 +0,0 @@ -import gleam/io -import gleam/int -import gleam/list - -pub fn main() { - let x = list.repeat(int.random(0, 5), times: int.random(0, 3)) - io.debug(x) - - let result = case x { - [] -> "Empty list" - [1] -> "List of just 1" - [4, ..] -> "List starting with 4" - [_, _] -> "List of 2 elements" - _ -> "Some other list" - } - io.debug(result) -} diff --git a/lessons/src/lesson025_list_patterns/text.html b/lessons/src/lesson025_list_patterns/text.html deleted file mode 100644 index de55eef..0000000 --- a/lessons/src/lesson025_list_patterns/text.html +++ /dev/null @@ -1,15 +0,0 @@ -

- 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