From 68986fe0410584c6934c835bb0ee784655f5f8c5 Mon Sep 17 00:00:00 2001 From: Rose Hogenson Date: Tue, 11 Jan 2022 22:01:23 -0800 Subject: Move scheme compiler into a separate directory. --- list.csc | 64 ---------------------------------------------------------------- 1 file changed, 64 deletions(-) delete mode 100644 list.csc (limited to 'list.csc') diff --git a/list.csc b/list.csc deleted file mode 100644 index f425146..0000000 --- a/list.csc +++ /dev/null @@ -1,64 +0,0 @@ -(define-library (csc list) - (export - enumerate - filter - intercalate - revappend - split-at - take) - (import (scheme base) - (only (csc match) - match)) - (begin - - - (define (take n xs) - (let loop ((n n) - (xs xs) - (acc '())) - (if (or (not (positive? n)) (null? xs)) - (reverse acc) - (loop (- n 1) (cdr xs) (cons (car xs) acc))))) - - - (define (split-at n xs) - (let loop ((n n) - (xs xs) - (acc '())) - (if (or (not (positive? n)) (null? xs)) - (values (reverse acc) xs) - (loop (- n 1) (cdr xs) (cons (car xs) acc))))) - - - (define (revappend a b) - (let loop ((xs a) - (acc b)) - (if (null? 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)))))) - - - (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)))))))) -- cgit v1.3.1