Author Topic: need a refresher on and / or  (Read 1857 times)

0 Members and 1 Guest are viewing this topic.

andrew_nao

  • Guest
need a refresher on and / or
« on: May 08, 2015, 03:03:43 PM »
im having a bit of a brain fart

is it
Code: [Select]
(if (and (or (= a b) (= b c))))
or
(if (or (and (= a b) (= b c))))


tombu

  • Bull Frog
  • Posts: 289
  • ByLayer=>Not0
Re: need a refresher on and / or
« Reply #1 on: May 08, 2015, 03:15:39 PM »
It's either
Code: [Select]
(if (or (= a b) (= b c)))
or
(if (and (= a b) (= b c)))
The extra and/or has only one argument, not sure what you're trying to do with it
Tom Beauford P.S.M.
Leon County FL Public Works - Windows 7 64 bit AutoCAD Civil 3D

PKENEWELL

  • Bull Frog
  • Posts: 320
Re: need a refresher on and / or
« Reply #2 on: May 08, 2015, 03:24:38 PM »
im having a bit of a brain fart

is it
Code: [Select]
(if (and (or (= a b) (= b c))))
or
(if (or (and (= a b) (= b c))))

Hi Andrew,

Your statements don't make sense becuase your outer AND and OR respectively only have one argument. If you write it out logically it make more sense - such as:

Code: [Select]
(if
   (and
      ; The below statement is True
      (or
         (= a b); This statement is True
         ;OR
         (= b c); This statement is True
      ) ; End OR
      ; AND
      ; The below statement is True
      (or
          (= d e) ;This statement is True
          ;OR
         (= f g) ;This statement is True
      ) ;End OR
   );End AND
) ;End IF
"When you are asked if you can do a job, tell 'em, 'Certainly I can!' Then get busy and find out how to do it." - Theodore Roosevelt

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: need a refresher on and / or
« Reply #3 on: May 08, 2015, 05:27:12 PM »
If it's an exact match you can use member or vl-position or assoc

Code: [Select]
_$ (member 8 '(2 4)
(
_$ (vl-position 8 '(2 4)
2
_1$ (assoc 8 '((2) (4) ())
(
(vl-some '(lambda (x) (= 8 x)) '(2 4)
T

Real numbers with rounding differences will not work without manipulation first.

So maybe this would be better
Code: [Select]
(vl-some '(lambda (x) (equal 8 x 0.00001)) '(2 4 8.000002))
T
(or (equal a b 0.00001)(equal b c 0.00001))

Just an FYI :)
« Last Edit: May 08, 2015, 05:39:02 PM by CAB »
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.