From: Tim Vaughan Date: Tue, 1 Nov 2016 08:38:20 +0000 (+1300) Subject: Implemented (reverse list). X-Git-Url: https://thelambdalab.xyz/gitweb/index.cgi?a=commitdiff_plain;h=9b75e5d50017b95ee8d10ade294c6676a1a60af4;p=scheme.forth.jl.git Implemented (reverse list). --- diff --git a/scheme-library.scm b/scheme-library.scm index 207bb30..dc345cf 100644 --- a/scheme-library.scm +++ b/scheme-library.scm @@ -21,6 +21,11 @@ (car lists) (join (car lists) (apply append (cdr lists)))))) +; Reverse the contents of a list +(define (reverse l) + (if (null? l) + () + (append (reverse (cdr l)) (list (car l))))) ;; LIBRARY FORMS (define-macro (let value . body ) diff --git a/scheme.4th b/scheme.4th index 57ee1e6..1d06ea6 100644 --- a/scheme.4th +++ b/scheme.4th @@ -1630,7 +1630,7 @@ variable gc-stack-depth include scheme-primitives.4th - \ s" scheme-library.scm" load 2drop + s" scheme-library.scm" load 2drop \ }}}