Page 1 of 1

Too few arguments, whats wrong with my code?

Posted: Wed Feb 01, 2012 9:13 pm
by felmor
hi, im new here.. I just have a difficulty on debugging my code..

Code: Select all

(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?

Posted: Thu Feb 02, 2012 8:47 am
by ramarren
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?

Posted: Thu Feb 02, 2012 8:18 pm
by felmor
funny when I realized that I can make this one simple. lol

Code: Select all

(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