I need some help... This might seem pretty simple to some people, but I'm really have difficulty figuring this problem out.

I need to add two numbers on using the increment(1+) and decrement(1-) functions.. I have the logic for adding work however I need help printing NIL if the user enters a non numeric value.. Any ideas.. I'm not sure how to implement the arguement with two values. I also know I need to use numberp, but that only accepts one value..

I've tried (and (numberp n)(numberp m)) which is the correct logic, but when I add this to my function I get an error that says:
"Function called with two arguements, but wants exactly one"

Thanks in advance!

11 Years
Discussion Span
Last Post by indienick

Hey man,

Seems like you have declared your function in this way:

(defun my-add (n) (...))

instead of this:

(defun my-add (m n) (...))

Hope this could help.



The logical condition is correct, but watch the syntax: (and (numberp n) (numberp m)) Try this:

(if (numberp m)
    (if (numberp n)
        (+ m n)
      ((lambda ()
         (format t "~%ERROR: N is not a number.")
  ((lambda ()
      (format t "~%ERROR: M is not a number.")))
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.