type

List of symbols:

callable?, char?, err?, io?, list?, nil?, ok?, pair?, seq?, str->float, string?, symbol?, vec?

callable?

Usage: (callable? v [SCRATCH] [SCRATCH] t)

Usage: (callable? to-test)

No Examples

char?

Usage: (char? expression)

True if the expression is a char, false otherwise.

Example:

(test::assert-true (char? \a))
(test::assert-false (char? 1))
(test::assert-false (char? "a"))

err?

Usage: (err? expression)

True if the expression is an error, false otherwise.

Example:

(test::assert-true (err? (mk-err :arr "test")))
(test::assert-false (err? nil))

io?

Usage: (io? expression)

True if the expression is an IO object (file), false otherwise.

Example:

(def iotst (fopen "/tmp/iotst" :create))
(test::assert-true (io? iotst))
(test::assert-false (io? 1))
(test::assert-false (io? '(1 2 3)))
(test::assert-false (io? (list)))

list?

Usage: (list? expression)

True if the expression is a list, false otherwise.

Example:

(test::assert-true (list? '(1 2 3)) "reader macro")
(test::assert-true (list? (list 1 2 3)) "list")
(test::assert-false (list? 1))
(test::assert-false (list? [1 2 3]))
(test::assert-false (list? []))
(test::assert-false (list? '(1 . 2)))

nil?

Usage: (nil? v)

True if the expression is nil, false otherwise

Example:

(test::assert-true (nil? ()))
(test::assert-true (nil? '()))
(test::assert-true (nil? nil))
(test::assert-true (nil? (list)))
(test::assert-false (nil? #f))

ok?

Usage: (ok? expression)

True if the expression is NOT an error, false if it is an error.

Example:

(test::assert-false (ok? (mk-err :arr "test")))
(test::assert-true (ok? nil))

pair?

Usage: (pair? expression)

True if the expression is a pair, false otherwise.

Example:

(test::assert-true (pair? '(1 . 2)) "reader macro")
(test::assert-true (pair? (cons 1 2)) "cons")
(test::assert-true (pair? '(1 2)))
(test::assert-false (pair? 1))
(test::assert-false (pair? [1 2 3]))
(test::assert-false (pair? (vec)))

seq?

Usage: (seq? expression)

True if expression is a list or vector, false otherwise.

Example:

(test::assert-true (seq? '(1 2 3)))
(test::assert-true (seq? [1 2 3]))
(test::assert-true (seq? []))
(test::assert-false (seq? "aaa"))
(test::assert-false (seq? 1))

str->float

Usage: (str->float string) -> float

If string is a valid representation of a float return that float. Error if not.

Example:

(test::assert-equal 0.0 (str->float "0"))
(test::assert-equal 10.0 (str->float "10.0"))
(test::assert-equal 10.5 (str->float "10.5"))
(test::assert-equal 101.0 (str->float "101"))
(test::assert-equal -101.95 (str->float "-101.95"))
(test::assert-error (str->float "not int"))
(test::assert-error (str->float "--10"))

string?

Usage: (string? expression)

True if the expression is a string, false otherwise.

Example:

(test::assert-true (string? "string"))
(test::assert-false (string? 1))

symbol?

Usage: (symbol? expression)

True if the expression is a symbol, false otherwise.

Example:

(test::assert-true (symbol? 'symbol))
(test::assert-false (symbol? 1))

vec?

Usage: (vec? expression)

True if the expression is a vector, false otherwise.

Example:

(test::assert-true (vec? [1 2 3]) "reader macro")
(test::assert-true (vec? (make-vec)) "make-vec")
(test::assert-true (vec? (vec 1 2 3)) "vec")
(test::assert-false (vec? 1))
(test::assert-false (vec? '(1 2 3)))
(test::assert-false (vec? (list)))