From 3024eac0b5743f08cfc2af6aa98ade17ced3a1f4 Mon Sep 17 00:00:00 2001 From: tomsmeding Date: Tue, 26 Nov 2019 18:00:18 +0100 Subject: Lisp parser in lisp can parse stdlib --- tests/stdlib.lisp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'tests/stdlib.lisp') diff --git a/tests/stdlib.lisp b/tests/stdlib.lisp index 88af2a1..9acee4b 100644 --- a/tests/stdlib.lisp +++ b/tests/stdlib.lisp @@ -86,6 +86,10 @@ (rec (cdr l2) (cons (car l2) rest)))))) (helper l '()))) +(define map (f l) + (if (null? l) l + (cons (f (car l)) (map f (cdr l))))) + (define stdin (sys-stdin)) (define stdout (sys-stdout)) (define stderr (sys-stderr)) @@ -120,3 +124,15 @@ (< num 0) (concat "-" (number->string (- 0 num))) (helper num "")))) + +(define concat-list (l) + (if (null? l) "" + (concat (car l) (concat-list (cdr l))))) + +(define intercalate (sep l) + (cond + (null? l) + "" + (null? (cdr l)) + (car l) + (concat (concat (car l) sep) (intercalate sep (cdr l))))) -- cgit v1.2.3-54-g00ecf