aboutsummaryrefslogtreecommitdiffstats
path: root/list.csc
diff options
context:
space:
mode:
Diffstat (limited to 'list.csc')
-rw-r--r--list.csc14
1 files changed, 12 insertions, 2 deletions
diff --git a/list.csc b/list.csc
index c4bc013..799b070 100644
--- a/list.csc
+++ b/list.csc
@@ -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))))))))