From: David Vazquez Date: Sun, 16 Dec 2012 23:54:26 +0000 (+0000) Subject: Append, reverse X-Git-Url: http://repo.macrolet.net/gitweb/?a=commitdiff_plain;h=592794a9432ed6a38ebd5b58a0770e3a4891b027;p=jscl.git Append, reverse --- 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)