Author Topic: When "/=" doesn't mean (not (equal))  (Read 3056 times)

0 Members and 1 Guest are viewing this topic.

whdjr

  • Guest
When "/=" doesn't mean (not (equal))
« on: September 20, 2004, 11:35:36 AM »
Can someone tell me why this does not work:
Code: [Select]
(setq sel (ss_get ":E:S"))
     (mapcar '(lambda (x)
(if (/= x obj)
  (ssdel x sel)
)
      )
     (ssnames sel)
     )


But this does work:
Code: [Select]
(setq sel (ss_get ":E:S"))
     (mapcar '(lambda (x)
(if (not (equal x obj))
  (ssdel x sel)
)
      )
     (ssnames sel)
     )




Here is the helper function SSNAMES:
Code: [Select]
(defun ssnames (selection_set / num lst)
  (repeat (setq num (sslength selection_set))
    (setq num (1- num)
 lst (cons (ssname selection_set num) lst)
    )
  )
  lst
)


This is baffling to me.  If someone can explain this please do.

Thanks,

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
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.

whdjr

  • Guest
When "/=" doesn't mean (not (equal))
« Reply #2 on: September 20, 2004, 11:48:48 AM »
So with all that being said by CAB, am I correct in the way I am using (not (equal)) in this application or is there some other way to show not equal without using "/=".

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
When "/=" doesn't mean (not (equal))
« Reply #3 on: September 20, 2004, 12:11:10 PM »
You are on the right track, but there is allways another way to write it.

Code: [Select]
(setq sel (ss_get ":E:S"))
(mapcar '(lambda (x)
           (if (eq x obj)
             (); do nothing
             (ssdel x sel)
           )
         )
        (ssnames sel)
)

(setq sel   (ss_get ":E:S"))
            (mapcar '(lambda (x)
             (cond ((eq x obj))((ssdel x sel))))
               (ssnames sel)
            )


PS revised the last code
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.

David Bethel

  • Swamp Rat
  • Posts: 656
When "/=" doesn't mean (not (equal))
« Reply #4 on: September 20, 2004, 12:34:52 PM »
Quote
(eq expr1 expr2)

The eq function determines whether expr1 and expr2 are bound to the same object (by setq, for example).



From VLisp A2K help.  -David
R12 Dos - A2K

whdjr

  • Guest
When "/=" doesn't mean (not (equal))
« Reply #5 on: September 20, 2004, 01:01:07 PM »
Thanks guy for the input.

I keep codin' the way I have it.