diff options
author | Sebastian <s@porto5.com> | 2021-04-27 11:46:54 +1000 |
---|---|---|
committer | Louis Pilfold <louis@lpil.uk> | 2021-04-29 20:24:23 +0100 |
commit | 747d13dcc84e64ffb23fbf958b7a279fa029dcb0 (patch) | |
tree | 0b84187d19ffc3f336b745602d7521b83f88ba94 /src | |
parent | 5240db2fc2e6ea7ed6577c1e6cc49d8c551aa2da (diff) | |
download | gleam_stdlib-747d13dcc84e64ffb23fbf958b7a279fa029dcb0.tar.gz gleam_stdlib-747d13dcc84e64ffb23fbf958b7a279fa029dcb0.zip |
Rename combination_by_2 to combination_pairs
Diffstat (limited to 'src')
-rw-r--r-- | src/gleam/list.gleam | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/gleam/list.gleam b/src/gleam/list.gleam index 869fc10..6170496 100644 --- a/src/gleam/list.gleam +++ b/src/gleam/list.gleam @@ -1480,12 +1480,12 @@ pub fn combinations(items: List(a), by n: Int) -> List(List(a)) { } } -fn do_combinations_by_2(items: List(a)) -> List(List(tuple(a, a))) { +fn do_combination_pairs(items: List(a)) -> List(List(tuple(a, a))) { case items { [] -> [] [x, ..xs] -> { let first_combinations = map(xs, with: fn(other) { tuple(x, other) }) - [first_combinations, combinations_by_2(xs)] + [first_combinations, combination_pairs(xs)] } } } @@ -1495,11 +1495,11 @@ fn do_combinations_by_2(items: List(a)) -> List(List(tuple(a, a))) { /// ## Examples /// /// ``` -/// > combinations_by_2([1, 2, 3]) +/// > combination_pairs([1, 2, 3]) /// [tuple(1, 2), tuple(1, 3), tuple(2, 3)] /// ``` /// -pub fn combinations_by_2(items: List(a)) -> List(tuple(a, a)) { - do_combinations_by_2(items) +pub fn combination_pairs(items: List(a)) -> List(tuple(a, a)) { + do_combination_pairs(items) |> flatten } |