From 592794a9432ed6a38ebd5b58a0770e3a4891b027 Mon Sep 17 00:00:00 2001 From: David Vazquez Date: Sun, 16 Dec 2012 23:54:26 +0000 Subject: [PATCH] Append, reverse --- test.lisp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/test.lisp b/test.lisp index 3abd8f5..f63710a 100644 --- a/test.lisp +++ b/test.lisp @@ -12,6 +12,21 @@ (%compile-defun ',name)) (fsetq ,name (lambda ,args ,@body)))) +(defun append (list1 list2) + (if (null list1) + list2 + (cons (car list1) + (append (cdr list1) list2)))) + +(defun reverse-aux (list acc) + (if (null list) + acc + (reverse-aux (cdr list) (cons (car list) acc)))) + +(defun reverse (list) + (reverse-aux list '())) + +(debug (reverse '(1 2 3 4))) ;;; Tests @@ -81,9 +96,6 @@ (debug (lambda (x y &rest z) x)) -(defun f (x) (* x x)) -(debug (f 33)) - ;; (eval-when-compile ;; (%compile-defmacro 'defun ;; (lambda (name args &rest body) -- 1.7.10.4