Light Dark

Functions

and core

fn (x: Any, rest): Any

Returns the first falsy value, or the last value if all are truthy. Short-circuits evaluation.

Example

and(true, true)       // true
and(true, false)      // false
and(false, true)      // false
and(1, 2, 3)          // 3 (all truthy, returns last)
and(1, null, 3)       // null (first falsy)

if core

fn (pred: Any, lazy then: Any): Any
fn (pred: Any, lazy then: Any, lazy else: Any): Any

If pred is truthy, return then, otherwise return else. Arguments are lazy-evaluated.

Example

if(true, "yes", "no")   // "yes"
if(false, "yes", "no")  // "no"

// Lazy evaluation prevents errors
x 0
if(eq(x, 0), "zero", div(10, x))  // "zero" - div never called

is-truthy core

fn (value: Any): Bool

Check if value is truthy (not false, null, or 0).

Example

is-truthy(true)    // true
is-truthy(1)       // true
is-truthy("hi")  // true
is-truthy(false)   // false
is-truthy(null)    // false

not core

fn (x: Any): Bool

Negate x. If x is truthy, return false, otherwise return true.

Example

not(true)   // false
not(false)  // true
not(null)   // true
not(1)      // false
not(0)      // true

or core

fn (x: Any, rest): Any

Returns the first truthy value, or the last value if all are falsy. Short-circuits evaluation.

Example

or(true, false)   // true
or(false, true)   // true
or(false, false)  // false
or(null, 0, 42)   // 42 (first truthy)
or(null, false)   // false (all falsy, returns last)