Too few arguments, whats wrong with my code?

Discussion of Common Lisp
Post Reply
felmor
Posts: 2
Joined: Wed Feb 01, 2012 9:09 pm

Too few arguments, whats wrong with my code?

Post by felmor » Wed Feb 01, 2012 9:13 pm

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. :)

ramarren
Posts: 613
Joined: Sun Jun 29, 2008 4:02 am
Location: Warsaw, Poland
Contact:

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

Post by ramarren » Thu Feb 02, 2012 8:47 am

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.

felmor
Posts: 2
Joined: Wed Feb 01, 2012 9:09 pm

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

Post by felmor » Thu Feb 02, 2012 8:18 pm

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

Post Reply