aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/gleam/list.gleam9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/gleam/list.gleam b/src/gleam/list.gleam
index 9acc6ce..c74bd20 100644
--- a/src/gleam/list.gleam
+++ b/src/gleam/list.gleam
@@ -488,6 +488,15 @@ if javascript {
}
}
+/// Prefixes an item to a list. This can also be done using the dedicated
+/// syntax instead
+///
+/// let new_list = [1, ..existing_list]
+///
+pub fn prepend(to list: List(a), item: a) -> List(a) {
+ [item, ..list]
+}
+
fn do_flatten(lists: List(List(a)), acc: List(a)) -> List(a) {
case lists {
[] -> acc