aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/list.gleam11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/list.gleam b/src/list.gleam
index 288d971..352fc77 100644
--- a/src/list.gleam
+++ b/src/list.gleam
@@ -263,3 +263,14 @@ pub fn range(start, stop) {
| order:Lt -> [start | range(start + 1, stop)]
}
}
+
+fn do_repeat(a, times, acc) {
+ case times <= 0 {
+ | True -> acc
+ | False -> do_repeat(a, times - 1, [a | acc])
+ }
+}
+
+pub fn repeat(a, times) {
+ do_repeat(a, times, [])
+}