diff options
author | Sebastian <s@porto5.com> | 2020-12-17 14:57:08 +1100 |
---|---|---|
committer | Louis Pilfold <louis@lpil.uk> | 2020-12-17 10:17:03 +0000 |
commit | e4d09202ab7d3b0a4bc52213858ce939b0a2a6dd (patch) | |
tree | 30a043fdcc3164604dfe76ee97a01162bec3a487 /test | |
parent | 095d936bfcbf239d84e329b267aea0d6ebf15d33 (diff) | |
download | gleam_stdlib-e4d09202ab7d3b0a4bc52213858ce939b0a2a6dd.tar.gz gleam_stdlib-e4d09202ab7d3b0a4bc52213858ce939b0a2a6dd.zip |
Add list.permutations
Diffstat (limited to 'test')
-rw-r--r-- | test/gleam/list_test.gleam | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/test/gleam/list_test.gleam b/test/gleam/list_test.gleam index ff94c3b..d9a4285 100644 --- a/test/gleam/list_test.gleam +++ b/test/gleam/list_test.gleam @@ -481,3 +481,26 @@ pub fn partition_test() { |> list.partition(int.is_odd) |> should.equal(tuple([1, 3, 5, 7], [2, 4, 6])) } + +pub fn permutations_test() { + [1, 2] + |> list.permutations + |> should.equal([[1, 2], [2, 1]]) + + let expected = [ + [1, 2, 3], + [1, 3, 2], + [2, 1, 3], + [2, 3, 1], + [3, 1, 2], + [3, 2, 1], + ] + + [1, 2, 3] + |> list.permutations + |> should.equal(expected) + + ["a", "b"] + |> list.permutations + |> should.equal([["a", "b"], ["b", "a"]]) +} |