Jump to content

Recommended Posts

Posted
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

  • Replies 23
  • Created
  • Last Reply

Top Posters In This Topic

  • KRBeckman

    9

  • Lee Mac

    8

  • David Bethel

    4

  • lpseifert

    2

Top Posters In This Topic

Posted

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.

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

Posted

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

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...