diff options
| author | Rose Hogenson <rhogenson@posteo.net> | 2022-01-09 22:55:59 -0800 |
|---|---|---|
| committer | Rose Hogenson <rhogenson@posteo.net> | 2022-01-09 22:55:59 -0800 |
| commit | 77583a881b03ce38c8065c40641489fe88b61eb2 (patch) | |
| tree | d4f65cfd698fee8e63168b4a5b64ab4123177fc3 /list.csc | |
| parent | b482a919615c0a5755a6828ad77d13e6c1b8b7a2 (diff) | |
| download | chromatopelma-77583a881b03ce38c8065c40641489fe88b61eb2.tar.zst | |
Write the linker.
Diffstat (limited to 'list.csc')
| -rw-r--r-- | list.csc | 23 |
1 files changed, 22 insertions, 1 deletions
@@ -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)))))))) |
