Author Topic: Single predicate function for non-nil atom?  (Read 3653 times)

0 Members and 1 Guest are viewing this topic.

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Single predicate function for non-nil atom?
« on: December 03, 2010, 01:06:31 PM »
To check for a non-nil list you can use this single function:
Code: [Select]
(vl-consp lst)Instead of:
Code: [Select]
(and lst (listp lst))
To check for a non-nil atom I still use:
Code: [Select]
(and at (atom at))
Is that the only way? Or is there perhaps a single predicate function that can accomplish the same?

Lee Mac

  • Seagull
  • Posts: 12912
  • London, England
Re: Single predicate function for non-nil atom?
« Reply #1 on: December 03, 2010, 01:43:09 PM »
Code: [Select]
(_atom at)
Code: [Select]
(defun _atom ( a ) (and a (atom a)))
 :lol:

David Bethel

  • Swamp Rat
  • Posts: 656
Re: Single predicate function for non-nil atom?
« Reply #2 on: December 03, 2010, 01:58:15 PM »
How about (boundp) ?  -David
R12 Dos - A2K

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: Single predicate function for non-nil atom?
« Reply #3 on: December 06, 2010, 10:27:25 AM »
Code: [Select]
(defun _atom (a) (and a (atom a)))
(setq
  a nil
  b 'a
  c 1
  d 'c
  lst '(1 2 3)
  ss (ssget "_X")
)

; (boundp 'a)   => nil
; (boundp 'b)   => T
; (boundp 'c)   => T
; (boundp 'd)   => T
; (boundp 'lst) => T
; (boundp 'ss)  => T

; (boundp a)   => nil
; (boundp b)   => nil
; (boundp c)   => nil
; (boundp d)   => T
; (boundp lst) => nil
; (boundp ss)  => nil

; (_atom a)   => nil
; (_atom b)   => T
; (_atom c)   => T
; (_atom d)   => T
; (_atom lst) => nil
; (_atom ss)  => T