diff options
author | Sebastian <s@porto5.com> | 2021-01-12 09:21:30 +1100 |
---|---|---|
committer | Louis Pilfold <louis@lpil.uk> | 2021-01-13 17:01:09 +0000 |
commit | 66b107b1902936411c8532113dcdd3d535176c05 (patch) | |
tree | 312bdf7f7294103b8d1304025ed7da1a6703e3df /test | |
parent | 955226b8ba73a51c7f4803f6ad54a75daf75ae24 (diff) | |
download | gleam_stdlib-66b107b1902936411c8532113dcdd3d535176c05.tar.gz gleam_stdlib-66b107b1902936411c8532113dcdd3d535176c05.zip |
Add try_fold
Diffstat (limited to 'test')
-rw-r--r-- | test/gleam/list_test.gleam | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/test/gleam/list_test.gleam b/test/gleam/list_test.gleam index 1c32878..dfc9693 100644 --- a/test/gleam/list_test.gleam +++ b/test/gleam/list_test.gleam @@ -177,6 +177,20 @@ pub fn index_fold_test() { |> should.equal([tuple(2, "c"), tuple(1, "b"), tuple(0, "a")]) } +pub fn try_fold_test() { + [1, 2, 3] + |> list.try_fold( + [], + fn(i, acc) { + case i < 3 { + True -> Ok([i, ..acc]) + False -> Error(acc) + } + }, + ) + |> should.equal([2, 1]) +} + pub fn find_map_test() { let f = fn(x) { case x { |