Kenpali Core Specification

The Core functions must be available to any Kenpali program. Reference implementations for some of them in terms of the others are provided by core.kpc, enabling a complete implementation with fewer builtins.

Arithmetic

Strings

Comparison

Logic

Types and Type Conversion

The typeOf function never returns "function", since there are two distinct types of functions: givens (functions defined within Kenpali) and builtins (functions defined in the host language).

Control Flow

The repeat function repeatedly updates a value by applying the specified next function. The function is applied until the next application would cause the while function to return false, i.e. the result is the last value for which while returns true.

Alternatively, you can pass a continueIf function. Then the result is the first value for which continueIf returns false.

Arrays

The build function generates an array by repeatedly applying a function to a start value, and transforming the resulting states into array elements.

As with repeat, there are two ways of specifying when the loop should end. If you pass a while function, the result array will contain only elements produced from states for which the while function returns true.

Or you can pass a continueIf function, in which case the result array will contain the elements produced from the first state for which continueIf returns false.

Since the out property is an array, an iteration can add multiple values to the result, or skip adding values entirely.

Objects

Sets and Maps

Mutable Objects

Errors

Validation