aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Kronqvist <joel.kronqvist@iki.fi>2025-08-16 02:05:10 +0300
committerJoel Kronqvist <joel.kronqvist@iki.fi>2025-08-16 02:05:10 +0300
commitbbbe6a4718deedb8ff19d6be15470e9af8a33e1c (patch)
tree614af8581d467e795df819fefb2bc6b39adeb0c7
parente35522189f5217987bc455d70c3b9056541ef8c6 (diff)
downloadmyslip-bbbe6a4718deedb8ff19d6be15470e9af8a33e1c.tar.gz
myslip-bbbe6a4718deedb8ff19d6be15470e9af8a33e1c.zip
feat: sum for lists/vectors in stdlib
-rw-r--r--stdlib.slip11
1 files changed, 11 insertions, 0 deletions
diff --git a/stdlib.slip b/stdlib.slip
index dce325a..e73674e 100644
--- a/stdlib.slip
+++ b/stdlib.slip
@@ -19,3 +19,14 @@
(- x 1)
)
)
+
+
+(let sum (fix
+ (fn sum' ((Int ...) -> Int) ((Int ...) -> Int)
+ (fn vec (Int ...) Int
+ (case vec
+ ((h ..t) (+ h (sum' t)))
+ (_ 0))
+ )
+ )
+))