diff options
Diffstat (limited to 'lessons/src/lesson021_list_functions/code.gleam')
-rw-r--r-- | lessons/src/lesson021_list_functions/code.gleam | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/lessons/src/lesson021_list_functions/code.gleam b/lessons/src/lesson021_list_functions/code.gleam new file mode 100644 index 0000000..8cd4ced --- /dev/null +++ b/lessons/src/lesson021_list_functions/code.gleam @@ -0,0 +1,15 @@ +import gleam/io +import gleam/list + +pub fn main() { + let ints = [0, 1, 2, 3, 4, 5] + + let doubled = list.map(ints, fn(x) { x * 2 }) + io.debug(doubled) + + let even = list.filter(ints, fn(x) { x % 2 == 0 }) + io.debug(even) + + let total = list.fold(ints, from: 0, with: fn(count, e) { count + e }) + io.debug(total) +} |