From 747d13dcc84e64ffb23fbf958b7a279fa029dcb0 Mon Sep 17 00:00:00 2001 From: Sebastian Date: Tue, 27 Apr 2021 11:46:54 +1000 Subject: Rename combination_by_2 to combination_pairs --- src/gleam/list.gleam | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src') 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 } -- cgit v1.2.3