aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorinoas <mail@inoas.com>2022-10-27 11:47:51 +0200
committerLouis Pilfold <louis@lpil.uk>2022-10-27 15:33:11 +0100
commitfef515c9897efc707e23aa8fd9a8752bf145b32c (patch)
tree5c95392e2ce99a08129386665c6591a79376b6eb
parent4b75aba3006f752fbaa1f810d703379e776be1dd (diff)
downloadgleam_stdlib-fef515c9897efc707e23aa8fd9a8752bf145b32c.tar.gz
gleam_stdlib-fef515c9897efc707e23aa8fd9a8752bf145b32c.zip
naming
-rw-r--r--src/gleam/list.gleam9
1 files changed, 5 insertions, 4 deletions
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))
}
}