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.

Comparing lists' values

5 posts · 1830 views

Hello there, I'm new to Lisp and I would like to know why this doesnt work.
I have this list
 (compare `((something 5) (qwer 3)) 2) 

and im trying to compare the 5 with the 2, but I get this error
Error: (5) is not of type (OR RATIONAL FLOAT). Is there anyway I can compare these two values?
(defun compare (L N)
	(if
		(> (cdr (car L)  N  ))
			T
	)
)

Re: Comparing lists' values

Try printing the values you are comparing.

Re: Comparing lists' values

I did and they are 5 and 2... so I don't understand why that error happens..

Re: Comparing lists' values

(cdar L) returns (5), not 5. You have to use (cadar L).

Re: Comparing lists' values

that error made me waste so much time until now, thanks!