lisp program error
Posted: Sun Oct 26, 2008 2:16 pm
Hello! I'm currently working on a lisp program that should increment a number stored in a list through its digits by 1. I've written a module that recieves the reversed list and a carry flag but it won't even compile, so I can't tell if I'm on the right path or not. Can you please look at the code and tell me where I'm screwing up? I'm a complete noob so it's probably just a syntax error. Thank you very much in advance.
Oh, and the error I get is:
Code: Select all
(DEFUN incr (X N)
(COND
((NULL X)
(COND
((= N 1) (1))
(T ())
)
)
(T
(+ (CAR X) 1)
(COND
((> (CAR X) 9) (- (CAR X) 10) (CONS ((CAR X) (incr (CDR X) 1))))
(T (CONS (CAR X) (incr (CDR X) 0)))
)
)
)
)
Code: Select all
;; Loading file /home/zephyr/Desktop/PLF/incr.lsp ...
WARNING: DEFUN/DEFMACRO: redefining function INCR in
/home/zephyr/Desktop/PLF/incr.lsp, was defined in
/home/zephyr/Desktop/PLF/incr2.lsp
*** - SYSTEM::%EXPAND-FORM: invalid form (1)
The following restarts are available:
SKIP :R1 skip (DEFUN INCR # ...)
STOP :R2 stop loading file /home/zephyr/Desktop/PLF/incr.lsp
ABORT :R3 ABORT
ABORT :R4 ABORT