Version -10.0.0
Each function, combinator, or definition should be documented here.
“not negative”
(Function, Boolean Predicate)
Integer on top of stack is replaced by Boolean value indicating whether it is non-negative.
N !-
----------- N < 0
false
N !-
---------- N >= 0
true
0 >=
“apply one”
(Combinator)
Given a quoted program on TOS and anything as the second stack item run the program without disturbing the stack and replace the two args with the first result of the program.
... x [Q] app1
---------------------------------
... [x ...] [Q] infra first
nullary popd
Just a specialization of nullary really. Its parallelizable cousins are more useful.
(Combinator)
Run two quoted programs
[P] [Q] b
---------------
P Q
[i] dip i
[P] [Q] b
[P] [Q] [i] dip i
[P] i [Q] i
P [Q] i
P Q
This combinator comes in handy.
(Combinator)
Run a quoted program using exactly two stack values and leave the first item of the result on the stack.
... y x [P] binary
-----------------------
... A
unary popd
Runs any other quoted function and returns its first result while consuming exactly two items from the stack.
(Function)
Given two items and a list, append the items to the list to make a new list.
B A [...] ccons
---------------------
[B A ...]
cons cons
Does cons twice.
(Basis Function)
Given an item and a list, append the item to the list to make a new list.
A [...] cons
------------------
[A ...]
func(cons, [list(A), B|S], [list([B|A])|S]).
Cons is a venerable old function from Lisp. It doesn’t inspect the item but it will not cons onto a non-list. It’s inverse operation is called uncons.
(Basis Combinator)
Append a quoted expression onto the pending expression.
[Q] i
-----------
Q
combo(i, [list(P)|S], S, Ei, Eo) :- append(P, Ei, Eo).
This is probably the fundamental combinator. You wind up using it in all kinds of places (for example, the x combinator can be defined as dup i.)
(Combinator)
Accept a quoted program and a list on the stack and run the program with the list as its stack. Does not affect the stack (below the list.)
... [a b c] [Q] infra
---------------------------
c b a Q [...] swaack
swons swaack [i] dip swaack
This is one of the more useful combinators. It allows a quoted expression to serve as a stack for a program, effectively running it in a kind of “pocket universe”. If the list represents a datastructure then infra lets you work on its internal structure.
(Combinator)
Run a quoted program without using any stack values and leave the first item of the result on the stack.
... [P] nullary
---------------------
... A
[stack] dip infra first
... [P] nullary
... [P] [stack] dip infra first
... stack [P] infra first
... [...] [P] infra first
... [A ...] first
... A
A very useful function that runs any other quoted function and returns it’s first result without disturbing the stack (under the quoted program.)
(Combinator)
Run a quoted program using exactly three stack values and leave the first item of the result on the stack.
... z y x [P] unary
-------------------------
... A
binary popd
Runs any other quoted function and returns its first result while consuming exactly three items from the stack.
(Combinator)
Run a quoted program using exactly one stack value and leave the first item of the result on the stack.
... x [P] unary
---------------------
... A
nullary popd
Runs any other quoted function and returns its first result while consuming exactly one item from the stack.
(Basis Function)
Removes an item from a list and leaves it on the stack under the rest of the list. You cannot uncons an item from an empty list.
[A ...] uncons
--------------------
A [...]
func(uncons, Si, So) :- func(cons, So, Si).
This is the inverse of cons.
(Combinator)
[F] x
-----------
[F] F
dup i
The x combinator …