-
Notifications
You must be signed in to change notification settings - Fork 0
Module std
The std module in EK provides a set of functions that are useful for writing programs in EK. It is not automatically imported and must be imported explicitly using the import keyword.
You may alternatively import another standard library, such as rpn which provides the same functionality as std but with a different syntax.
An integer value of arbitrary size.
A boolean value, either true or false.
A string value, such as "Hello, world!".
Any value.
An atom indicating that there is no necessary value.
A 64-bit floating-point value.
fn print (value: any): void
Prints the value to the standard output, followed by a newline.
fn eprint (value: any): void
Prints the value to the standard error, followed by a newline.
fn readLine: string
Reads a line from the standard input.
fn exit (code: int): void
Exits the program with the given exit code (between 0 and 255).
fn assert (condition: bool) message (str: string): void
Asserts that the given condition is true. If it is not, the program will exit with an exit code of 1 and print the given message to the standard error.
fn panic (message: string): void
Exits the program with an exit code of 1 and prints the given message to the standard error.
fn clamp (value: int) min (min: int) max (max: int): int
Clamps the given value between the given minimum and maximum values.
fn (a: int) min (b: int): int
fn (a: int) max (b: int): int
Returns the minimum/maximum of the two given values.
fn (value: any) toString: string
Returns a string representation of the given value.
fn if (condition: bool) then (lazy then: any) else (lazy otherwise: any): any
Returns the then value if the condition is true, otherwise returns the otherwise value.
fn (a: int) + (b: int) precedence 6: int
fn (a: int) - (b: int) precedence 6: int
fn (a: int) * (b: int) precedence 7: int
fn (a: int) / (b: int) precedence 7: int
Returns the sum/difference/product/quotient of the two given values.
fn (a: any) == (b: any) precedence 4: bool
fn (a: any) != (b: any) precedence 4: bool
Returns true if the two given values are equal/not equal.
fn (a: int) < (b: int) precedence 4: bool
fn (a: int) <= (b: int) precedence 4: bool
fn (a: int) > (b: int) precedence 4: bool
fn (a: int) >= (b: int) precedence 4: bool
Returns true if the first value is less than/equal to/greater than/equal to the second value.
fn (a: bool) && (lazy b: bool) precedence 3: bool
fn (a: bool) || (lazy b: bool) precedence 2: bool
Returns the logical AND/OR of the two given booleans. The second value is only evaluated if necessary.
fn not (value: bool) precedence 9: bool
Returns the logical NOT of the given boolean.
fn (a: any) >> (b: t) precedence 1: t
Returns the second value after evaluating the first value.
fn (f: a -> b) $ (value: a) precedence 0: b
Returns the result of applying the function f to the value value.
fn (f: b -> c) . (g: a -> b) precedence 9: a -> c
Returns the composition of the two given functions.