Lee Mac Posted February 5, 2010 Posted February 5, 2010 I'm not a big fan ( eq ) Just look at the example of the help files: (setq f1 '(a b c)) (setq f2 '(a b c)) (setq f3 f2) Compare f1 and f3: Command: (eq f1 f3) nil For that matter: (eq f1 f2) returns nil It's just not that intuitive for me. I do use it for comparing ENAMEs in that are they are bound to symbols. (=) converts strings to their ASCII numbers and compares them that way. (= "Z" "z") returns nil -David Thanks David, I think I've seen something like that before http://www.theswamp.org/index.php?topic=29839.msg354144#msg354144 Quote
David Bethel Posted February 5, 2010 Posted February 5, 2010 Another one can be strange is (/=) (/= 1 1 2 1 1) returns nil ( at least up until 2000 ) whereas (not (= 1 1 2 1 1)) returns T I never quite understood the reasoning: AutoLISP Reference Note that the behavior of /= does not quite conform to other LISP dialects. The standard behavior is to return T if no two arguments in the list have the same value. In AutoLISP, /= returns T if no successive arguments have the same value; see the examples that follow. Examples (/= 10 20) returns T (/= "you" "you") returns nil (/= 5.43 5.44) returns T (/= 10 20 10 20 20) returns nil (/= 10 20 10 20) returns T Note in the last example that although there are two arguments in the list with the same value, they do not follow one another, and thus /= evaluates to T. Quote
SteveK Posted February 6, 2010 Posted February 6, 2010 Note in the last example that although there are two arguments in the list with the same value, they do not follow one another, and thus /= evaluates to T. Interesting... If (= 1 1 2 2) & (/= 1 1 2 2) both return nil does that mean /= compares them in pairs whereas = compares all args? Then (not (= 1 1 2 1 1)) returns T makes sense because (= 1 1 2 1 1) is nil. Are these results consistant with Lisp in general or just AutoLisp? Quote
David Bethel Posted February 6, 2010 Posted February 6, 2010 SteveK Interesting... does that mean /= compares them in pairs as sequential pairs as I understand it: (/= 10 20 10 20) returns T would compare (= 10 20) then (= 20 10) then (= 10 20) None of these return T so the /= call returns T Are these results consistant with Lisp in general or just AutoLisp? It's just AutoLsip as far as I know. -David Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.