Reference

Casting

To number

Input An argument of any type.
Output The argument converted to a number.

Signature

to_number(a: Any): Number

Example

to_number("42") // returns 42

To integer

Input An argument of any type.
Output The argument converted to an integer.

Signature

to_integer(a: Any): Number

Example

to_integer(3.7) // returns 3

To decimal

Input An argument of any type.
Output The argument converted to a decimal number.

Signature

to_decimal(a: Any): Number

Example

to_decimal("3.14") // returns 3.14

To string

Input An argument of any type.
Output The argument converted to a string.

Signature

to_string(a: Any): String

Example

to_string(42) // returns "42"

To boolean

Input A string, number, or boolean. Strings convert to true if non-empty after trimming. Numbers convert to true if non-zero. Booleans pass through unchanged. Other types throw an error.
Output The argument converted to a boolean.

Signature

to_boolean(a: Any): Boolean

Example

to_boolean(1) // returns true

To list

Input A set, vector, stack, or queue. Other types throw an error.
Output The argument converted to a list.

Signature

to_list(a: Any): List

Example

to_list(set_new([1, 2, 3])) // returns [1, 2, 3]

Is number

Input An argument of any type.
Output True if the argument is a number. False otherwise.

Signature

is_number(a: Any): Boolean

Example

is_number(42) // returns true

Is integer

Input An argument of any type.
Output True if the argument is an integer. False otherwise.

Signature

is_integer(a: Any): Boolean

Example

is_integer(3) // returns true

Is decimal

Input An argument of any type.
Output True if the argument is a decimal number. False otherwise.

Signature

is_decimal(a: Any): Boolean

Example

is_decimal(3.14) // returns true

Is infinite

Input An argument of any type.
Output True if the argument is infinite. False otherwise.

Signature

is_infinite(a: Any): Boolean

Example

is_infinite(num_infinity()) // returns true

Is string

Input An argument of any type.
Output True if the argument is a string. False otherwise.

Signature

is_string(a: Any): Boolean

Example

is_string("hello") // returns true

Is boolean

Input An argument of any type.
Output True if the argument is a boolean. False otherwise.

Signature

is_boolean(a: Any): Boolean

Example

is_boolean(true) // returns true

Is timestamp

Input An argument of any type.
Output True if the argument is a timestamp. False otherwise.

Signature

is_timestamp(a: Any): Boolean

Example

is_timestamp(time_now()) // returns true

Is function

Input An argument of any type.
Output True if the argument is a function. False otherwise.

Signature

is_function(a: Any): Boolean

Example

is_function(num_add) // returns true

Is list

Input An argument of any type.
Output True if the argument is a list. False otherwise.

Signature

is_list(a: Any): Boolean

Example

is_list([1, 2, 3]) // returns true

Is map

Input An argument of any type.
Output True if the argument is a map. False otherwise.

Signature

is_map(a: Any): Boolean

Example

is_map({"a": 1}) // returns true

Is vector

Input An argument of any type.
Output True if the argument is a vector. False otherwise.

Signature

is_vector(a: Any): Boolean

Example

is_vector(vector_new([1, 2])) // returns true

Is set

Input An argument of any type.
Output True if the argument is a set. False otherwise.

Signature

is_set(a: Any): Boolean

Example

is_set(set_new([1, 2])) // returns true

Is stack

Input An argument of any type.
Output True if the argument is a stack. False otherwise.

Signature

is_stack(a: Any): Boolean

Example

is_stack(stack_new([1, 2])) // returns true

Is queue

Input An argument of any type.
Output True if the argument is a queue. False otherwise.

Signature

is_queue(a: Any): Boolean

Example

is_queue(queue_new([1, 2])) // returns true

Is file

Input An argument of any type.
Output True if the argument is a file. False otherwise.

Signature

is_file(a: Any): Boolean

Example

is_file(file_fromPath("data.txt")) // returns true

Is directory

Input An argument of any type.
Output True if the argument is a directory. False otherwise.

Signature

is_directory(a: Any): Boolean

Example

is_directory(directory_fromPath("/home")) // returns true

Is duration

Input An argument of any type.
Output True if the argument is a duration. False otherwise.

Signature

is_duration(a: Any): Boolean

Example

is_duration(duration_fromHours(2)) // returns true