From fef515c9897efc707e23aa8fd9a8752bf145b32c Mon Sep 17 00:00:00 2001 From: inoas Date: Thu, 27 Oct 2022 11:47:51 +0200 Subject: naming --- src/gleam/list.gleam | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/gleam/list.gleam b/src/gleam/list.gleam index ddb062a..04d311e 100644 --- a/src/gleam/list.gleam +++ b/src/gleam/list.gleam @@ -530,18 +530,19 @@ pub fn prepend(to list: List(a), item: a) -> List(a) { [item, ..list] } -fn prepend_list_reverse(list prefix: List(a), to suffix: List(a)) -> List(a) { +// Reverses a list and prepends it to another list +fn reverse_and_prepend(list prefix: List(a), to suffix: List(a)) -> List(a) { case prefix { [] -> suffix - [head, ..tail] -> prepend_list_reverse(tail, [head, ..suffix]) + [head, ..tail] -> reverse_and_prepend(list: tail, to: [head, ..suffix]) } } fn do_flatten(lists: List(List(a)), acc: List(a)) -> List(a) { case lists { [] -> reverse(acc) - [a_list, ..rest_lists] -> - do_flatten(rest_lists, prepend_list_reverse(a_list, acc)) + [list, ..further_lists] -> + do_flatten(further_lists, reverse_and_prepend(list: list, to: acc)) } } -- cgit v1.2.3