A
type predicate
tests if an
object
belongs to a
type of object
. Most of these types are Lisp types, which can be found in the Classes
of the OMKernel / Lisp
package, or added in patches via data boxes.
Type predicates are not available in the OM menus or packages, but their name can be typed in a patch editor directly. It conventionally ends in the letter "p" for "predicate".
There are several number types, which can be tested by the following predicates.
|
|
|
|
By extension, other predicates test the properties of numbers.
|
|
|
|
|
Here are some of the most frequently used type predicates in OM :
Predicate |
Returns "t" for |
Example |
---|---|---|
characterp |
the name of a character that has a printable glyph. |
#\Space ; #\a ... -> t |
symbolp |
something that can be named but numbers, strings, lists, some characters. |
'cow ; note ; 2-ERz -> t |
atom |
anything not between parenthesis but strings. |
A ; 38 ; -> t |
listp |
anything between parenthesis, or nil. In Lisp, nil = empty list. |
(A B C) ; (A (B C) -> t |
consp |
(A B) ; (A (B C)) -> t (A) -> nil | |
stringp |
anything between inverted commas. |
"vangogh#\Tab;;2" -> t |
functionp |
function names and function boxes on "lambda" mode. |
|
nullp |
anything that is nil. |
nil -> t ; ( ) -> t |
typep |
an object of a given type. |
|
Elementary Lisp functions, allowing the access to one or more elements in a list. CAR and CDR are kernel functions upon which have been defined the rest of these functions.
Let the following list be : (A B C D).
CAR (A B C D) = A.
CDR (A B C D) = (B C D).
CADR (A B C D) = B. CADR means CAR of the CDR.
CDDR (A B C D) = (C D). CDDR means CDR of the CDR.
CADDR (A B C D) = C. CADDR means CAR of the CDDR.
NTHCDR (A B C D) = NTH CDR of the list – N must be specified as argument. NTHCDR 3 (A B C D) = (D).
And so on...