Author Topic: Checking a list ...  (Read 1991 times)

0 Members and 1 Guest are viewing this topic.

Hangman

  • Swamp Rat
  • Posts: 566
Checking a list ...
« on: September 28, 2010, 05:54:46 PM »
Afternoon everyone,
I'm having a brain cramp and can't seem to get a simple return, so I'm coming to you guys.

I have the following:
Code: [Select]
(setq var-a '(1.1 2.2 3.3))
Quote
Command: !a
(0.0 1.1 2.2)

Now if I want to check var-a, I THOUGHT I would type the following:
Code: [Select]
(if (= var-a '(1.1 2.2 3.3))(ALERT "Yahoo"))What I get is
Quote
nil

How do I verify the value of var-a ?

Thanks.
Hangman  8)

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Drafting Board, Mechanical Arm, KOH-I-NOOR 0.7mm
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Checking a list ...
« Reply #1 on: September 28, 2010, 05:56:57 PM »
Maybe try ' equal ' or ' eq ' or maybe even throw in a fuzz factor with one of them.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: Checking a list ...
« Reply #2 on: September 28, 2010, 05:57:41 PM »
Be careful with the various equality tests...

Code: [Select]

Command: (= '(1 2 3) '(1 2 3))
nil

Command: (eq '(1 2 3) '(1 2 3))
nil

Command: (equal '(1 2 3) '(1 2 3))
T

Similarly for enames:

Code: [Select]
Command: (setq e (car (entsel)))

Select object: <Entity name: 7ef03940>

Command: (setq f (car (entsel)))

Select object: <Entity name: 7ef03940>

Command: (= e f)
nil

Command: (eq e f)
T

Command: (equal e f)
T

Hangman

  • Swamp Rat
  • Posts: 566
Re: Checking a list ...
« Reply #3 on: September 28, 2010, 06:03:59 PM »
Ohh, ...
EQ & EQUAL

And Equal has the Fuzz factor, thanks Tim.

Thank you guys.  Sorry for the stupidity I'm portraying today.
Hangman  8)

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Drafting Board, Mechanical Arm, KOH-I-NOOR 0.7mm
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~