x-lang

← Index

x/core/predicates

null?

Test if a value is nil (the empty list).

Parameters:

Returns: BOOL — t if nil

Examples:

(null? ()) => #t
(null? '(1)) => #f

pair?

Test if a value is a pair (cons cell).

Parameters:

Returns: BOOL — t if pair

Examples:

(pair? '(1)) => #t
(pair? ()) => #f

not

Logical negation.

Parameters:

Returns: BOOL — t if x is falsy

Examples:

(not #f) => #t
(not 0) => #f

atom?

Test if a value is an atom (not a pair).

Parameters:

Returns: BOOL — t if not a pair

Examples:

(atom? 5) => #t
(atom? '(1)) => #f

number?

Test if a value is an integer.

Parameters:

Returns: BOOL — t if integer

Examples:

(number? 42) => #t
(number? "42") => #f

real?

Test if a value is a real number: a number that is not complex. The number modules extend it in place as they load.

Parameters:

Returns: BOOL — t if real

Examples:

(real? 42) => #t
(real? 'a) => #f

str?

Test if a value is a string.

Parameters:

Returns: BOOL — t if string

Examples:

(str? "a") => #t
(str? 'a) => #f

symbol?

Test if a value is a symbol.

Parameters:

Returns: BOOL — t if symbol

Examples:

(symbol? 'a) => #t
(symbol? "a") => #f

char?

Test if a value is a character.

Parameters:

Returns: BOOL — t if character

Examples:

(char? #\a) => #t
(char? "a") => #f

procedure?

Test if a value is callable (procedure or primitive).

Parameters:

Returns: BOOL — t if procedure or primitive

Examples:

(procedure? list) => #t
(procedure? 'list) => #f

operative?