Predicates & Type Checking
Predicates return #t or #f and conventionally end with ?.
Emptiness Predicates
null?
Test if a value is the empty list.
(null? '()) ; => #t
(null? '(1)) ; => #fnil?
Test if a value is nil.
(nil? nil) ; => #t
(nil? 0) ; => #fempty?
Test if a collection or string is empty.
(empty? "") ; => #t
(empty? '()) ; => #t
(empty? "hello") ; => #fCollection Predicates
list?
Test if a value is a list.
(list? '(1)) ; => #t
(list? 42) ; => #fpair?
Test if a value is a non-empty list (Scheme compatibility).
(pair? '(1 2)) ; => #t
(pair? '()) ; => #fvector?
Test if a value is a vector.
(vector? [1]) ; => #t
(vector? '(1)) ; => #fmap?
Test if a value is a map.
(map? {:a 1}) ; => #t
(map? '()) ; => #fNumeric Predicates
number?
Test if a value is a number (integer or float).
(number? 42) ; => #t
(number? 3.14) ; => #t
(number? "42") ; => #finteger?
Test if a value is an integer.
(integer? 42) ; => #t
(integer? 3.14) ; => #ffloat?
Test if a value is a floating-point number.
(float? 3.14) ; => #t
(float? 42) ; => #fzero?
Test if a number is zero.
(zero? 0) ; => #t
(zero? 1) ; => #feven?
Test if an integer is even.
(even? 4) ; => #t
(even? 3) ; => #fodd?
Test if an integer is odd.
(odd? 3) ; => #t
(odd? 4) ; => #fpositive?
Test if a number is positive.
(positive? 1) ; => #t
(positive? -1) ; => #fnegative?
Test if a number is negative.
(negative? -1) ; => #t
(negative? 1) ; => #fType Predicates
string?
Test if a value is a string.
(string? "hi") ; => #t
(string? 42) ; => #fsymbol?
Test if a value is a symbol.
(symbol? 'x) ; => #t
(symbol? "x") ; => #fkeyword?
Test if a value is a keyword.
(keyword? :k) ; => #t
(keyword? "k") ; => #fchar?
Test if a value is a character.
(char? #\a) ; => #t
(char? "a") ; => #fbool?
Test if a value is a boolean. boolean? is an alias.
(bool? #t) ; => #t
(bool? 0) ; => #ffn?
Test if a value is a function. procedure? is an alias.
(fn? car) ; => #t
(fn? 42) ; => #frecord?
Test if a value is a record instance.
(record? my-record) ; => #t
(record? 42) ; => #fbytevector?
Test if a value is a bytevector.
(bytevector? #u8()) ; => #t
(bytevector? '()) ; => #fPromise Predicates
promise?
Test if a value is a promise (created with delay).
(promise? (delay 1)) ; => #t
(promise? 42) ; => #fpromise-forced?
Test if a promise has been forced (evaluated).
(define p (delay (+ 1 2)))
(promise-forced? p) ; => #f
(force p)
(promise-forced? p) ; => #tEquality
eq?
Test structural equality. equal? is an alias.
(eq? 'a 'a) ; => #t
(eq? '(1 2) '(1 2)) ; => #t
(eq? 1 2) ; => #f=
Numeric equality.
(= 1 1) ; => #t
(= 1 1.0) ; => #t
(= 1 2) ; => #fLLM Type Predicates
prompt?
Test if a value is an LLM prompt.
(prompt? (prompt (user "hi"))) ; => #tmessage?
Test if a value is an LLM message.
(message? (message :user "hi")) ; => #tconversation?
Test if a value is a conversation.
(conversation? (conversation/new {})) ; => #ttool?
Test if a value is a tool definition.
(deftool my-tool "A test tool" {:x {:type :string}} (lambda (x) x))
(tool? my-tool) ; => #t
(tool? 42) ; => #fagent?
Test if a value is an agent.
(defagent my-agent {:system "test"})
(agent? my-agent) ; => #t
(agent? 42) ; => #f