aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorSebastian Porto <s@porto5.com>2021-04-08 21:48:12 +1000
committerLouis Pilfold <louis@lpil.uk>2021-04-09 10:39:19 +0100
commit895bb26dd125d946653c53897e73bdf88ae5555d (patch)
tree649b6f423fc4c8bd419230ee593421a423e940d8 /test
parent8d83506941b16722aed6eab102565bfd163ba053 (diff)
downloadgleam_stdlib-895bb26dd125d946653c53897e73bdf88ae5555d.tar.gz
gleam_stdlib-895bb26dd125d946653c53897e73bdf88ae5555d.zip
Add list.map_reduce
Diffstat (limited to 'test')
-rw-r--r--test/gleam/list_test.gleam6
1 files changed, 6 insertions, 0 deletions
diff --git a/test/gleam/list_test.gleam b/test/gleam/list_test.gleam
index b561d33..fa87952 100644
--- a/test/gleam/list_test.gleam
+++ b/test/gleam/list_test.gleam
@@ -99,6 +99,12 @@ pub fn map_test() {
|> should.equal([0, 8, 10, 14, 6])
}
+pub fn map_reduce_test() {
+ [1, 2, 3, 4]
+ |> list.map_reduce(from: 0, with: fn(acc, i) { tuple(acc + i, i * 2) })
+ |> should.equal(tuple(10, [2, 4, 6, 8]))
+}
+
pub fn try_map_test() {
let fun = fn(x) {
case x == 6 || x == 5 || x == 4 {