aboutsummaryrefslogtreecommitdiff
path: root/src/content/chapter4_standard_library/lesson01_list_module/en.html
blob: 9c6b953cf3dc5f188c7e1800575f00657ed76bef (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<p>
  The
  <a href="https://hexdocs.pm/gleam_stdlib/gleam/list.html" target="_blank">
    <code>gleam/list</code>
  </a>
  standard library module contains functions for working with lists. A Gleam
  program will likely make heavy use of this module, the various functions
  serving as different types of loops over lists.
</p>

<p>
  <a href="https://hexdocs.pm/gleam_stdlib/gleam/list.html#map" target="_blank">
    <code>map</code>
  </a>
  makes a new list by running a function on each element in a list.
</p>
<p>
  <a href="https://hexdocs.pm/gleam_stdlib/gleam/list.html#filter" target="_blank">
    <code>filter</code>
  </a>
  makes a new list containing only the elements for which a function returns
  true.
</p>
<p>
  <a href="https://hexdocs.pm/gleam_stdlib/gleam/list.html#fold" target="_blank">
    <code>fold</code>
  </a>
  combines all the elements in a list into a single value by running a function
  left-to-right on each element, passing the result of the previous call to the
  next call.
</p>
<p>
  <a href="https://hexdocs.pm/gleam_stdlib/gleam/list.html#find" target="_blank">
    <code>find</code>
  </a>
  returns the first element in a list for which a function returns
  <code>True</code>.
</p>
<p>
  It's worth getting familiar with all the functions in this module when writing
  Gleam code, you'll be using them a lot!
</p>