User Tools

Site Tools


ch2_3_predic

This is an old revision of the document!


Predicates

Simple functions that return T or NIL.

EQ

Tests if to arguments are the same symbol, accepts only symbols or NIL.

>(eq 'pi 'user::pi)
T
 
>(eq 'nil ())    ; NIL, 'NIL, () and '() are all EQ
T

EQUAL

Tests if two things are the same, is case and type senstive.

NOT

Logical not. Accepts single argument.

>(not 13)
NIL
 
>(not '())    
T

ATOM

Tests if the argument is an atom.

>(atom 13)
T
 
>(atom nil)    ; NIL is an atom (and list)
T
 
>(atom '())    ; this is still NIL  
T
 
>(atom '(a b)) ; this is list  
NIL

CONSP

Tests if the argument is a cons cell.

>(consp '())       ; NIL is not cons
NIL
 
>(consp '(a b))
T

LISTP

Tests if the argument is a list, that means cons-cell or nil.

>(listp nil)          ; NIL is a list (and atom)
T
 
>(listp '(a b))
T
 
>(listp (cons 'a 'b)) ; this is conscell with B in cdr, improper list
T

PROPER-LIST-P

Tests if the argument is a proper list. Proper list means list ending with NIL in the cdr of the last cons cell. Improper list might be dotted, or even cyclic.

>(proper-list-p (cons 'a 'b)) ; this is conscell with B in cdr, improper list
NIL

SYMBOLP

Tests if the argument is symbol. All versions of NIL are symbol.

>(symbolp 'a)          ; symbol A
T
 
>(symbolp 13)
NIL
 
>(symbolp nil)          ; symbol NIL
T

STRINGP

Tests if the argument is a string.

>(stringp "hello")          
T
 
>(stringp 'hello) 
NIL

NUMBERP

INTEGERP

ZEROP

ODDP

EVENP

FUNCTIONP

PACKAGEP

BOUNDP

FBOUNDP

SPECIAL-OPERATOR-P

ch2_3_predic.1646320837.txt.gz · Last modified: 2022/03/03 08:20 by admin

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki