From 36c767cf7058cca2c63f1a74161133f2492648e8 Mon Sep 17 00:00:00 2001 From: Louis Pilfold Date: Thu, 18 Jan 2024 20:37:36 +0000 Subject: Remove paragraph covered by previous lesson --- .../lesson07_list_recursion/text.html | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) (limited to 'src/content/chapter2_flow_control') diff --git a/src/content/chapter2_flow_control/lesson07_list_recursion/text.html b/src/content/chapter2_flow_control/lesson07_list_recursion/text.html index 7f2351d..94e8152 100644 --- a/src/content/chapter2_flow_control/lesson07_list_recursion/text.html +++ b/src/content/chapter2_flow_control/lesson07_list_recursion/text.html @@ -1,22 +1,19 @@

- Most commonly functions in the - gleam/list - module are used to iterate across a list, but at times you may prefer - to work with the list directly. + Most commonly functions in the + gleam/list + module are used to iterate across a list, but at times you may prefer to work + with the list directly.

-

- Gleam doesn't have a looping syntax, instead iteration is done through - recursion and pattern matching. -

The [first, ..rest] pattern matches on a list with at least one element, assigning the first element to the variable first and - the rest of the list to the variable rest. - By using this pattern and a pattern for the empty list [] a - function can run code on each element of a list until the end is reached. + the rest of the list to the variable rest. By using this pattern + and a pattern for the empty list [] a function can run code on + each element of a list until the end is reached.

This code sums a list by recursing over the list and adding each int to a total argument, returning it when the end is reached.

- -- cgit v1.2.3