diff options
| author | Rose Hogenson <rhogenson@posteo.net> | 2022-01-09 13:17:20 -0800 |
|---|---|---|
| committer | Rose Hogenson <rhogenson@posteo.net> | 2022-01-09 13:17:20 -0800 |
| commit | 6b8be199ae88979e508f98fb8a8b6fc17c2a7f2d (patch) | |
| tree | 38a11e7c79208f612356086022561f00d5c22e48 /list.csc | |
| parent | Improve match syntax. (diff) | |
| download | chromatopelma-6b8be199ae88979e508f98fb8a8b6fc17c2a7f2d.tar.zst | |
Define helper intercalate.
Diffstat (limited to 'list.csc')
| -rw-r--r-- | list.csc | 14 |
1 files changed, 12 insertions, 2 deletions
@@ -1,9 +1,12 @@ (define-library (csc list) (export + intercalate revappend split-at take) - (import (scheme base)) + (import (scheme base) + (only (csc match) + match)) (begin @@ -30,4 +33,11 @@ (acc b)) (if (null? xs) acc - (loop (cdr xs) (cons (car xs) acc))))))) + (loop (cdr xs) (cons (car xs) acc))))) + + + (define (intercalate x l) + (match l + ('() '()) + ((_) l) + ((head . tail) (cons head (cons x (intercalate x tail)))))))) |
