aboutsummaryrefslogtreecommitdiff
path: root/src/content/chapter2_flow_control/lesson04_list_patterns/code.gleam
blob: 1b71feb7ad380cd2287408068ed217b38c1db738 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import gleam/int
import gleam/io
import gleam/list

pub fn main() {
  let x = list.repeat(int.random(5), times: int.random(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)
}