This is a read-only archive of lispforum.com. The forum was locked to new users and posts and is preserved here as static HTML from a database snapshot taken on 2019-09-07.

Too few arguments, whats wrong with my code?

3 posts · 2337 views

hi, im new here.. I just have a difficulty on debugging my code..
(defun noun()
(print "Enter First Sentence:")
	(setq n(read))
(print "Enter Second Setence:")
	(setq m(read))

(cond
	((equal
		(nth '0 '(n))
		(nth '0 '(m)) (print "equal")

)) ((print "not equal"))

))
I only use notepad for coding, I'm newbie at this. thanks in advance. :)

Re: Too few arguments, whats wrong with my code?

You should really be using a parentheses-aware editor, like Emacs, although most modern editors support parentheses highlighting. The particular problem is that you have (print "equal") as a third argument to EQUAL function, while you presumably want it to be the execution branch of COND.

Variables should be established with LET. Doing SETQ on undeclared variables has undefined consequences. I recommend reading a book like Practical Common Lisp, which explains concepts in proper order and uses standard style in the examples.

Re: Too few arguments, whats wrong with my code?

funny when I realized that I can make this one simple. lol
(defun noun()
(print "Enter First Sentence:")
   (setq n(read))
(print "Enter Second Setence:")
   (setq m(read))

(cond
   ((equal (n m) (print "equal")

)) ((print "not equal"))
I'm gonna make this display the subjects later, that's my self assignment. thanks for the infos Ramarren :D