aboutsummaryrefslogtreecommitdiffstats
path: root/list.csc
diff options
context:
space:
mode:
authorRose Hogenson <rhogenson@posteo.net>2022-01-09 22:55:59 -0800
committerRose Hogenson <rhogenson@posteo.net>2022-01-09 22:55:59 -0800
commit77583a881b03ce38c8065c40641489fe88b61eb2 (patch)
treed4f65cfd698fee8e63168b4a5b64ab4123177fc3 /list.csc
parentb482a919615c0a5755a6828ad77d13e6c1b8b7a2 (diff)
downloadchromatopelma-77583a881b03ce38c8065c40641489fe88b61eb2.tar.zst
Write the linker.
Diffstat (limited to 'list.csc')
-rw-r--r--list.csc23
1 files changed, 22 insertions, 1 deletions
diff --git a/list.csc b/list.csc
index 799b070..f425146 100644
--- a/list.csc
+++ b/list.csc
@@ -1,5 +1,7 @@
(define-library (csc list)
(export
+ enumerate
+ filter
intercalate
revappend
split-at
@@ -40,4 +42,23 @@
(match l
('() '())
((_) l)
- ((head . tail) (cons head (cons x (intercalate x tail))))))))
+ ((head . tail) (cons head (cons x (intercalate x tail))))))
+
+
+ (define (enumerate l)
+ (let loop ((i 0)
+ (l l))
+ (match l
+ ('() '())
+ ((head . tail) (cons (cons i head) (loop (+ 1 i) tail))))))
+
+
+ (define (filter p l)
+ (let loop ((l l)
+ (acc '()))
+ (match l
+ ('() (reverse acc))
+ ((x . xs)
+ (if (p x)
+ (loop xs (cons x acc))
+ (loop xs acc))))))))