Delambda
Delambda is a successor to Unlambda created by User:Shadow Kestrel in 2022. Its syntax and semantics are largely identical to Unlambda, except for the removal of intrinsic functionality from .x
functions, removal of the c
, e
, @
, ?x
and |
functions, and the addition of the o
function. This makes the core of Delambda an effectively pure implementation of the SKI combinators with other terms being defineable therein. Additionally, the standard i/o streams are encoded in UTF-8 as opposed to being left unspecified.
The o function
I/O is handled by the o
function. If the program evaluates to an expression of the form ``oAB
then an action is taken depending on A, then B is applied to the result. For example, ``o`ki`s`ki
would read one character from the standard input (corresponding to `ki
). Supposing the character read were ě (UTF-8 code c4 9b) then execution would resume as ``s`ki``<cons><church numeral 0xc4>``<cons><church numeral 0x9b><nil>
.
Any values taken or given as a "list" are defined with <cons> = ``s``s`ks``s`kk``s`ks``s`k`si``s`kki`k``s`kki; <nil> = `sk
The functionality of ``oAB
is as follows:
A | Behaviour |
---|---|
``.x.y.z |
Writes "zyx" to stdout |
k |
Reads the entirety of stdin and returns it as a list of lists (per character, final character deepest) of church numerals (bytewise, LSB deepest). Returns <nil> upon failure.
|
`ki |
Reads a single character from stdin and returns it as a list of church numerals (bytewise, LSB deepest). Returns <nil> upon failure.
|
`kx |
If x is a list of church numerals forming a valid UTF-8 character, returns a .x function for that character. Else, returns v
|
s |
Returns a church numeral, whose binary form denotes the capabilities of the implementation. Any form of `sx or ``sxy is reserved for such functionalities.
|
Any other term not of the form ``sAB | Error and terminate |
Implementation-specific functionality
A Delambda implementation is not required to implement all these functions, as some may not be available in the parent language.
File I/O
Available if `os
bit 0 (LSB) is 1. From path ``si
.
A | Behaviour |
---|---|
``sii |
Reads from a file, prompting user for choice. Returns a list containing the file name (list of bytes, ASCII) and raw data (list of bytes), or <nil> if it fails.
|
``si`kx |
Reads from file x, assuming x is a valid sequence of ASCII .x functions. Returns the raw data of the file as a list of bytes or <nil> if it fails.
|
``si``sif |
Writes the list of bytes f to a file, prompting user for choice. Returns k , or `ki if unsuccessful.
|
``si`s`kxf |
Writes the list of bytes f to file x, assuming x is a valid sequence of ASCII .x functions. Returns k , or `ki if unsuccessful.
|
Basic Canvas
Available if `os
bit 1 is 1. From path ``s`k
.
A | Behaviour |
---|---|
``s`kxy |
Creates a new canvas of width x and height y, and returns an actionless function corresponding to it. |
``s`kCv |
Destroys canvas C and returns k or `ki in the event of failure. Note that losing all references to a canvas without destroying it is undefined behaviour and should be avoided. |
``s`k``sxy`sCl |
Draws pixel (x,y) with colour l on canvas C, returning C. (A colour is a list of three church numerals less than 256 representing RGB) |