diff options
-rw-r--r-- | net/ricketyspace/sicp/two/eighteen.scm | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/net/ricketyspace/sicp/two/eighteen.scm b/net/ricketyspace/sicp/two/eighteen.scm new file mode 100644 index 0000000..f2ac60e --- /dev/null +++ b/net/ricketyspace/sicp/two/eighteen.scm @@ -0,0 +1,14 @@ +;;;; License: CC0-1.0 + +(define-module (net ricketyspace sicp two eighteen) + #:use-module (net ricketyspace sicp two seventeen) + #:export (sicp-reverse)) + +(define (sicp-append list1 list2) + (if (null? list1) + list2 + (cons (car list1) (sicp-append (cdr list1) list2)))) + +(define (sicp-reverse items) + (cond ((null? items) '()) + (else (sicp-append (sicp-reverse (cdr items)) (list (car items)))))) |