TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: whdjr on September 20, 2004, 11:35:36 AM

Title: When "/=" doesn't mean (not (equal))
Post by: whdjr 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,
Title: When "/=" doesn't mean (not (equal))
Post by: CAB on September 20, 2004, 11:39:36 AM
http://theswamp.org/phpBB2/viewtopic.php?t=2480
Title: When "/=" doesn't mean (not (equal))
Post by: whdjr 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 "/=".
Title: When "/=" doesn't mean (not (equal))
Post by: CAB 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
Title: When "/=" doesn't mean (not (equal))
Post by: David Bethel 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
Title: When "/=" doesn't mean (not (equal))
Post by: whdjr on September 20, 2004, 01:01:07 PM
Thanks guy for the input.

I keep codin' the way I have it.