Synsema docsENES

Builtins index

A categorized map of the built-ins. The full signatures live on each topic page; the core ones are doctested here so this reference can't drift.

builtins.syn
-- Doc reference: a few core builtins, doctested so the reference can't drift.
intent: "doc reference: core builtins"

print("upper(\"hi\") = " + upper("hi") + ",  join([a,b],\"-\") = " + join(["a", "b"], "-"))

test "collections"
    assert_eq(length([1, 2, 3]), 3)
    assert(contains([1, 2, 3], 2))
    assert_eq(slice([1, 2, 3, 4], 1, 3), [2, 3])     -- Python-style end-exclusive
    assert_eq(keys({"a": 1, "b": 2}), ["a", "b"])
    assert_eq(values({"a": 1, "b": 2}), [1, 2])

test "text"
    assert_eq(upper("hi"), "HI")
    assert_eq(trim("  x  "), "x")
    assert_eq(split("a,b,c", ","), ["a", "b", "c"])
    assert_eq(join(["a", "b"], "-"), "a-b")
    assert(starts_with("hello", "he"))

test "intentional ops"
    assert_eq(apply((n) => n * 2, [1, 2, 3]), [2, 4, 6])
    assert_eq(where([1, 2, 3, 4], (n) => n > 2), [3, 4])
    assert_eq(reduce([1, 2, 3], (a, b) => a + b, 0), 6)

By category