aboutsummaryrefslogtreecommitdiff
path: root/stdlib.slip
diff options
context:
space:
mode:
authorJoel Kronqvist <joel.kronqvist@iki.fi>2025-08-23 10:34:15 +0300
committerJoel Kronqvist <joel.kronqvist@iki.fi>2025-08-23 10:34:15 +0300
commit9a9f78a8dab77f476f82eb218c3d71aef55f13ec (patch)
tree89831fa21883d25650c7999f6ae382ea70e0df72 /stdlib.slip
parenta99eebca28c3046f5c50a0a65dbb9a2e4b047637 (diff)
downloadmyslip-9a9f78a8dab77f476f82eb218c3d71aef55f13ec.tar.gz
myslip-9a9f78a8dab77f476f82eb218c3d71aef55f13ec.zip
feat: repeat in stdlib
Diffstat (limited to 'stdlib.slip')
-rw-r--r--stdlib.slip19
1 files changed, 19 insertions, 0 deletions
diff --git a/stdlib.slip b/stdlib.slip
index dcedafc..2568354 100644
--- a/stdlib.slip
+++ b/stdlib.slip
@@ -67,6 +67,25 @@
))
+(let repeat
+ (fn (fun n) ((Int -> Nil) Int) Nil
+
+ ((let repeat-inner (fix
+ (fn repeat-inner' (((Int -> Nil) Int Int) -> Nil)
+ (((Int -> Nil) Int Int) -> Nil)
+ (fn (fun index until) ((Int -> Nil) Int Int) Nil
+ (case (<= index until)
+ (true (discard (fun index) (repeat-inner' fun (++ index) until)))
+ (_ ()))
+ )
+ )
+ ))
+
+ (repeat-inner fun 1 n))
+ )
+)
+
+
(let left-or
(fn (sum def) ((Sum L R) L) L
(case sum