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"

Hey man,

Seems like you have declared your function in this way:

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

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

Hope this could help.

Jim

It's logically correct, but watch the spacing: `(and (numberp n) (numberp m))`

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.")
nil)))
((lambda ()
(format t "~%ERROR: M is not a number.")))``````
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.