**//Predicates//**
Simple functions that return ''T'' or ''NIL''. They have no side effects.
''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.
>(equal "aa" "AA")
NIL
>(equal 1 1.0) ; different type
NIL
''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 a 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''
Tests if the argument is a number (integer or float).
>(numberp pi)
T
>(numberp (/ 10 5))
T
>(numberp (/ 10 0))
;Division by zero.
NIL
''INTEGERP''
Tests if the argument is a integer number.
>(integerp (/ 10 5)) ; integer division
T
>(integerp (/ 10 5.0)) ; poisoned by float 5.0
NIL
''ZEROP''
Tests if the argument is number zero.
>(zerop (- 10 10))
T
>(zerop nil)
;Applying ZEROP on non-numeric data type!
NIL
''ODDP''
Tests if the argument is an odd integer.
>(oddp 3)
T
>(oddp 3.0)
;Applying ODDP on non-integral number!
NIL
''EVENP''
Tests if the argument is an even integer.
>(evenp 2)
T
>(evenp 0)
T
''FUNCTIONP''
Tests if the argument is a function object.
>(functionp #'+)
T
''PACKAGEP''
Tests if the argument is a package object.
>(packagep *package*)
T
''BOUNDP''
Expects symbol as argument. Tests if the symbol has value binding.
>(boundp 'pi)
T
''FBOUNDP''
Expects symbol as argument. Tests if the symbol has function or macro binding.
>(fboundp '+)
T
>(fboundp 'if) ; also works for special forms
T
''SPECIAL-OPERATOR-P''
Expects symbol as argument. Tests if the symbol represents special operator.
>(special-operator-p '+) ; ordinary function
NIL
>(special-operator-p 'if) ; special operator IF
T