60 KiB
Functor Reference
Version -10.0.0
Each function, combinator, or definition should be documented here.
&
Basis Function Combinator
Same as a & b.
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
&&
Basis Function Combinator
nulco [nullary [false]] dip branch
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
*
Basis Function Combinator
Same as a * b.
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
•
Basis Function Combinator
The identity function.
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
^
Basis Function Combinator
Same as a ^ b.
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
=
Basis Function Combinator
Same as a == b.
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
!=
Basis Function Combinator
Same as a != b.
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
!-^^^^
Basis Function Combinator
0 >=
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
>
Basis Function Combinator
Same as a > b.
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
>=
Basis Function Combinator
Same as a >= b.
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
>>
Basis Function Combinator
Same as a >> b.
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
Functor Reference
Version -10.0.0
Each function, combinator, or definition should be documented here.
-^^^
Basis Function Combinator
Same as a - b.
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
--^^^^
Basis Function Combinator
Decrement TOS.
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
<
Basis Function Combinator
Same as a < b.
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
<=
Basis Function Combinator
Same as a <= b.
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
<>
Basis Function Combinator
Same as a != b.
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
<
Basis Function Combinator
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
<<
Basis Function Combinator
Same as a << b.
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
<<
Basis Function Combinator
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
%
Basis Function Combinator
Same as a % b.
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
+
Basis Function Combinator
Same as a + b.
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
++
Basis Function Combinator
Increment TOS.
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
?
Basis Function Combinator
dup bool
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
/
Basis Function Combinator
Same as a // b.
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
//
Basis Function Combinator
Same as a // b.
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
/floor
Basis Function Combinator
Same as a // b.
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
||
Basis Function Combinator
nulco [nullary] dip [true] branch
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
abs
Basis Function Combinator
Return the absolute value of the argument.
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
add
Basis Function Combinator
Same as a + b.
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
anamorphism
Basis Function Combinator
pop \[
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
and
Basis Function Combinator
Same as a & b.
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
app1
"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
Definition
nullary popd
Discussion
Just a specialization of nullary really. Its parallelizable cousins
are more useful.
app2
Basis Function Combinator
- Like app1 with two items.
-
... y x [Q] . app2 ----------------------------------- ... [y ...] [Q] . infra first [x ...] [Q] infra first
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
app3
Basis Function Combinator
- Like app1 with three items.
-
... z y x [Q] . app3 ----------------------------------- ... [z ...] [Q] . infra first [y ...] [Q] infra first [x ...] [Q] infra first
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
appN
Basis Function Combinator
grabN
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
at
Basis Function Combinator
getitem == drop first
Expects an integer and a quote on the stack and returns the item at the nth position in the quote counting from 0. :
[a b c d] 0 getitem
-------------------------
a
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
average
Basis Function Combinator
sum
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
b
(Combinator)
Run two quoted programs
[P] [Q] b
---------------
P Q
Definition
[i] dip i
Derivation
[P] [Q] b
[P] [Q] [i] dip i
[P] i [Q] i
P [Q] i
P Q
Discussion
This combinator comes in handy.
Crosslinks
binary
(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
Definition
unary popd
Discussion
Runs any other quoted function and returns its first result while consuming exactly two items from the stack.
Crosslinks
bool
Basis Function Combinator
bool(x) -> bool
Returns True when the argument x is true, False otherwise. The builtins True and False are the only two instances of the class bool. The class bool is a subclass of the class int, and cannot be subclassed.
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
branch
Basis Function Combinator
Use a Boolean value to select one of two quoted programs to run.
branch == roll< choice i
False [F] [T] branch
--------------------------
F
True [F] [T] branch
-------------------------
T
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
ccccons
Basis Function Combinator
ccons ccons
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
ccons
(Function)
Given two items and a list, append the items to the list to make a new list.
B A [...] ccons
---------------------
[B A ...]
Definition
cons cons
Discussion
Does cons twice.
Crosslinks
choice
Basis Function Combinator
Use a Boolean value to select one of two items. :
A B false choice
----------------------
A
A B true choice
---------------------
B
Currently Python semantics are used to evaluate the "truthiness" of the Boolean value (so empty string, zero, etc. are counted as false, etc.)
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
clear
Basis Function Combinator
- Clear everything from the stack.
-
clear == stack [pop stack] loop
... clear ---------------
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
cleave
Basis Function Combinator
fork popdd
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
clop
Basis Function Combinator
cleave popdd
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
cmp
Basis Function Combinator
cmp takes two values and three quoted programs on the stack and runs one of the three depending on the results of comparing the two values: :
a b [G] [E] [L] cmp
------------------------- a > b
G
a b [G] [E] [L] cmp
------------------------- a = b
E
a b [G] [E] [L] cmp
------------------------- a < b
L
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
codi
Basis Function Combinator
cons dip
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
codireco
Basis Function Combinator
codi reco
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
concat
Basis Function Combinator
Concatinate the two lists on the top of the stack. :
[a b c] [d e f] concat
----------------------------
[a b c d e f]
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
cond
Basis Function Combinator
This combinator works like a case statement. It expects a single quote on the stack that must contain zero or more condition quotes and a default quote. Each condition clause should contain a quoted predicate followed by the function expression to run if that predicate returns true. If no predicates return true the default function runs.
It works by rewriting into a chain of nested [ifte]{.title-ref} expressions, e.g.:
[[[B0] T0] [[B1] T1] [D]] cond
-----------------------------------------
[B0] [T0] [[B1] [T1] [D] ifte] ifte
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
cons
(Basis Function)
Given an item and a list, append the item to the list to make a new list.
A [...] cons
------------------
[A ...]
Source
func(cons, [list(A), B|S], [list([B|A])|S]).
Discussion
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.
Crosslinks
dinfrirst
Basis Function Combinator
dip infrst
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
dip
Basis Function Combinator
The dip combinator expects a quoted program on the stack and below it some item, it hoists the item into the expression and runs the program on the rest of the stack. :
... x [Q] dip
-------------------
... Q x
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
dipd
Basis Function Combinator
Like dip but expects two items. :
... y x [Q] dip
---------------------
... Q y x
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
dipdd
Basis Function Combinator
Like dip but expects three items. :
... z y x [Q] dip
-----------------------
... Q z y x
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
disenstacken
Basis Function Combinator
The disenstacken operator expects a list on top of the stack and makes that the stack discarding the rest of the stack.
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
div
Basis Function Combinator
Same as a // b.
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
divmod
Basis Function Combinator
divmod(x, y) -> (quotient, remainder)
Return the tuple (x//y, x%y). Invariant: q * y + r == x.
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
down_to_zero
Basis Function Combinator
0 \>
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
drop
Basis Function Combinator
drop == [rest] times
Expects an integer and a quote on the stack and returns the quote with n items removed off the top. :
[a b c d] 2 drop
----------------------
[c d]
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
dup
Basis Function Combinator
(a1 -- a1 a1)
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
dupd
Basis Function Combinator
(a2 a1 -- a2 a2 a1)
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
dupdd
Basis Function Combinator
(a3 a2 a1 -- a3 a3 a2 a1)
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
dupdip
Basis Function Combinator
[F] dupdip == dup [F] dip
... a [F] dupdip
... a dup [F] dip
... a a [F] dip
... a F a
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
dupdipd
Basis Function Combinator
dup dipd
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
enstacken
Basis Function Combinator
stack [clear] dip
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
eq
Basis Function Combinator
Same as a == b.
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
first
Basis Function Combinator
([a1 ...1] -- a1)
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
first_two
Basis Function Combinator
([a1 a2 ...1] -- a1 a2)
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
flatten
Basis Function Combinator
<{} [concat] step
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
floor
Basis Function Combinator
Return the floor of x as an Integral.
This is the largest integer <= x.
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
floordiv
Basis Function Combinator
Same as a // b.
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
fork
Basis Function Combinator
i
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
fourth
Basis Function Combinator
([a1 a2 a3 a4 ...1] -- a4)
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
gcd
Basis Function Combinator
true [tuck mod dup 0 >] loop pop
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
gcd2
Basis Function Combinator
Compiled GCD function.
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
ge
Basis Function Combinator
Same as a >= b.
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
genrec
Basis Function Combinator
General Recursion Combinator. :
[if] [then] [rec1] [rec2] genrec
---------------------------------------------------------------------
[if] [then] [rec1 [[if] [then] [rec1] [rec2] genrec] rec2] ifte
From "Recursion Theory and Joy" (j05cmp.html) by Manfred von Thun: "The genrec combinator takes four program parameters in addition to whatever data parameters it needs. Fourth from the top is an if-part, followed by a then-part. If the if-part yields true, then the then-part is executed and the combinator terminates. The other two parameters are the rec1-part and the rec2-part. If the if-part yields false, the rec1-part is executed. Following that the four program parameters and the combinator are again pushed onto the stack bundled up in a quoted form. Then the rec2-part is executed, where it will find the bundled form. Typically it will then execute the bundled form, either with i or with app2, or some other combinator."
The way to design one of these is to fix your base case [then] and the test [if], and then treat rec1 and rec2 as an else-part "sandwiching" a quotation of the whole function.
For example, given a (general recursive) function 'F': :
F == [I] [T] [R1] [R2] genrec
If the [I] if-part fails you must derive R1 and R2 from: :
... R1 [F] R2
Just set the stack arguments in front, and figure out what R1 and R2 have to do to apply the quoted [F] in the proper way. In effect, the genrec combinator turns into an ifte combinator with a quoted copy of the original definition in the else-part: :
F == [I] [T] [R1] [R2] genrec
== [I] [T] [R1 [F] R2] ifte
Primitive recursive functions are those where R2 == i. :
P == [I] [T] [R] tailrec
== [I] [T] [R [P] i] ifte
== [I] [T] [R P] ifte
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
getitem
Basis Function Combinator
getitem == drop first
Expects an integer and a quote on the stack and returns the item at the nth position in the quote counting from 0. :
[a b c d] 0 getitem
-------------------------
a
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
grabN
Basis Function Combinator
<{} [cons] times
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
grba
Basis Function Combinator
stack popd
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
gt
Basis Function Combinator
Same as a > b.
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
help
Basis Function Combinator
Accepts a quoted symbol on the top of the stack and prints its docs.
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
hypot
Basis Function Combinator
sqr
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
i
(Basis Combinator)
Append a quoted expression onto the pending expression.
[Q] i
-----------
Q
Source
combo(i, [list(P)|S], S, Ei, Eo) :- append(P, Ei, Eo).
Discussion
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.)
id
Basis Function Combinator
The identity function.
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
ifte
Basis Function Combinator
If-Then-Else Combinator :
... [if] [then] [else] ifte
---------------------------------------------------
... [[else] [then]] [...] [if] infra select i
... [if] [then] [else] ifte
-------------------------------------------------------
... [else] [then] [...] [if] infra first choice i
Has the effect of grabbing a copy of the stack on which to run the if-part using infra.
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
ii
Basis Function Combinator
... a [Q] ii
------------------
... Q a Q
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
infra
(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
Definition
swons swaack [i] dip swaack
Discussion
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.
Crosslinks
infrst
Basis Function Combinator
infra first
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
inscribe
Basis Function Combinator
Create a new Joy function definition in the Joy dictionary. A definition is given as a quote with a name followed by a Joy expression. for example:
sqr dup mul
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
le
Basis Function Combinator
Same as a <= b.
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
loop
Basis Function Combinator
Basic loop combinator. :
... True [Q] loop
-----------------------
... Q [Q] loop
... False [Q] loop
------------------------
...
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
lshift
Basis Function Combinator
Same as a << b.
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
lt
Basis Function Combinator
Same as a < b.
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
make_generator
Basis Function Combinator
codireco
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
map
Basis Function Combinator
Run the quoted program on TOS on the items in the list under it, push a new list with the results in place of the program and original list.
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
max
Basis Function Combinator
Given a list find the maximum.
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
min
Basis Function Combinator
Given a list find the minimum.
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
mod
Basis Function Combinator
Same as a % b.
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
modulus
Basis Function Combinator
Same as a % b.
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
mul
Basis Function Combinator
Same as a * b.
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
ne
Basis Function Combinator
Same as a != b.
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
neg
Basis Function Combinator
Same as -a.
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
not
Basis Function Combinator
Same as not a.
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
!-
"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
Definition
0 >=
nulco
Basis Function Combinator
nullary
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
nullary
(Combinator)
Run a quoted program without using any stack values and leave the first item of the result on the stack.
... [P] nullary
---------------------
... A
Definition
[stack] dip infra first
Derivation
... [P] nullary
... [P] [stack] dip infra first
... stack [P] infra first
... [...] [P] infra first
... [A ...] first
... A
Discussion
A very useful function that runs any other quoted function and returns it's first result without disturbing the stack (under the quoted program.)
Crosslinks
of
Basis Function Combinator
swap at
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
or
Basis Function Combinator
Same as a | b.
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
over
Basis Function Combinator
(a2 a1 -- a2 a1 a2)
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
pam
Basis Function Combinator
i
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
pick
Basis Function Combinator
getitem == drop first
Expects an integer and a quote on the stack and returns the item at the nth position in the quote counting from 0. :
[a b c d] 0 getitem
-------------------------
a
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
pm
Basis Function Combinator
Plus or minus :
a b pm
-------------
a+b a-b
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
pop
Basis Function Combinator
(a1 --)
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
popd
Basis Function Combinator
(a2 a1 -- a1)
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
popdd
Basis Function Combinator
(a3 a2 a1 -- a2 a1)
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
popop
Basis Function Combinator
(a2 a1 --)
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
popopd
Basis Function Combinator
(a3 a2 a1 -- a1)
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
popopdd
Basis Function Combinator
(a4 a3 a2 a1 -- a2 a1)
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
popopop
Basis Function Combinator
pop popop
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
pow
Basis Function Combinator
Same as a ** b.
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
pred
Basis Function Combinator
Decrement TOS.
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
primrec
Basis Function Combinator
From the "Overview of the language JOY":
> The primrec combinator expects two quoted programs in addition to a data parameter. For an integer data parameter it works like this: If the data parameter is zero, then the first quotation has to produce the value to be returned. If the data parameter is positive then the second has to combine the data parameter with the result of applying the function to its predecessor.:
5 [1] [*] primrec
> Then primrec tests whether the top element on the stack (initially the 5) is equal to zero. If it is, it pops it off and executes one of the quotations, the [1] which leaves 1 on the stack as the result. Otherwise it pushes a decremented copy of the top element and recurses. On the way back from the recursion it uses the other quotation, [*], to multiply what is now a factorial on top of the stack by the second element on the stack.:
n [Base] [Recur] primrec
0 [Base] [Recur] primrec
------------------------------
Base
n [Base] [Recur] primrec
------------------------------------------ n > 0
n (n-1) [Base] [Recur] primrec Recur
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
product
Basis Function Combinator
1 swap [*] step
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
quoted
Basis Function Combinator
unit
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
range
Basis Function Combinator
0 \<=
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
range_to_zero
Basis Function Combinator
unit [down_to_zero] infra
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
reco
Basis Function Combinator
rest cons
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
rem
Basis Function Combinator
Same as a % b.
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
remainder
Basis Function Combinator
Same as a % b.
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
remove
Basis Function Combinator
Expects an item on the stack and a quote under it and removes that item from the the quote. The item is only removed once. If the list is empty or the item isn't in the list then the list is unchanged. :
[1 2 3 1] 1 remove
------------------------
[2 3 1]
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
rest
Basis Function Combinator
([a1 ...0] -- [...0])
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
reverse
Basis Function Combinator
Reverse the list on the top of the stack. :
reverse == [] swap shunt
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
rolldown
Basis Function Combinator
(a1 a2 a3 -- a2 a3 a1)
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
rollup
Basis Function Combinator
(a1 a2 a3 -- a3 a1 a2)
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
roll>
Basis Function Combinator
(a1 a2 a3 -- a3 a1 a2)
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
roll<
Basis Function Combinator
(a1 a2 a3 -- a2 a3 a1)
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
round
Basis Function Combinator
Round a number to a given precision in decimal digits.
The return value is an integer if ndigits is omitted or None. Otherwise the return value has the same type as the number. ndigits may be negative.
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
rrest
Basis Function Combinator
([a1 a2 ...1] -- [...1])
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
rshift
Basis Function Combinator
Same as a >> b.
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
run
Basis Function Combinator
<{} infra
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
second
Basis Function Combinator
([a1 a2 ...1] -- a2)
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
select
Basis Function Combinator
Use a Boolean value to select one of two items from a sequence. :
[A B] false select
------------------------
A
[A B] true select
-----------------------
B
The sequence can contain more than two items but not fewer. Currently Python semantics are used to evaluate the "truthiness" of the Boolean value (so empty string, zero, etc. are counted as false, etc.)
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
sharing
Basis Function Combinator
Print redistribution information.
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
shift
Basis Function Combinator
uncons [swons] dip
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
shunt
Basis Function Combinator
Like concat but reverses the top list into the second. :
shunt == [swons] step == reverse swap concat
[a b c] [d e f] shunt
---------------------------
[f e d a b c]
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
size
Basis Function Combinator
pop ++
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
sort
Basis Function Combinator
Given a list return it sorted.
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
spiral_next
Basis Function Combinator
\[\[abs
\[++
ifte
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
split_at
Basis Function Combinator
drop
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
split_list
Basis Function Combinator
take reverse
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
sqr
Basis Function Combinator
dup *
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
sqrt
Basis Function Combinator
Return the square root of the number a. Negative numbers return complex roots.
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
stack
Basis Function Combinator
(... -- ... [...])
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
stackd
Basis Function Combinator
stack
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
step
Basis Function Combinator
Run a quoted program on each item in a sequence. :
... [] [Q] . step
-----------------------
... .
... [a] [Q] . step
------------------------
... a . Q
... [a b c] [Q] . step
----------------------------------------
... a . Q [b c] [Q] step
The step combinator executes the quotation on each member of the list on top of the stack.
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
step_zero
Basis Function Combinator
0 roll> step
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
stuncons
Basis Function Combinator
(... a1 -- ... a1 a1 [...])
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
stununcons
Basis Function Combinator
(... a2 a1 -- ... a2 a1 a1 a2 [...])
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
sub
Basis Function Combinator
Same as a - b.
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
succ
Basis Function Combinator
Increment TOS.
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
sum
Basis Function Combinator
Given a quoted sequence of numbers return the sum. :
sum == 0 swap [+] step
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
swaack
Basis Function Combinator
([...1] -- [...0])
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
swap
Basis Function Combinator
(a1 a2 -- a2 a1)
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
swapd
Basis Function Combinator
swap
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
swoncat
Basis Function Combinator
swap concat
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
swons
Basis Function Combinator
([...1] a1 -- [a1 ...1])
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
tailrec
Basis Function Combinator
i
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
take
Basis Function Combinator
Expects an integer and a quote on the stack and returns the quote with just the top n items in reverse order (because that's easier and you can use reverse if needed.) :
[a b c d] 2 take
----------------------
[b a]
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
ternary
(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
Definition
binary popd
Discussion
Runs any other quoted function and returns its first result while consuming exactly three items from the stack.
Crosslinks
third
Basis Function Combinator
([a1 a2 a3 ...1] -- a3)
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
times
Basis Function Combinator
times == [-- dip] cons [swap] infra [0 >] swap while pop :
... n [Q] . times
--------------------- w/ n <= 0
... .
... 1 [Q] . times
-----------------------
... . Q
... n [Q] . times
------------------------------------- w/ n > 1
... . Q (n - 1) [Q] times
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
truthy
Basis Function Combinator
bool(x) -> bool
Returns True when the argument x is true, False otherwise. The builtins True and False are the only two instances of the class bool. The class bool is a subclass of the class int, and cannot be subclassed.
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
tuck
Basis Function Combinator
(a2 a1 -- a1 a2 a1)
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
unary
(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
Definition
nullary popd
Discussion
Runs any other quoted function and returns its first result while consuming exactly one item from the stack.
Crosslinks
uncons
(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 [...]
Source
func(uncons, Si, So) :- func(cons, So, Si).
Discussion
This is the inverse of cons.
Crosslinks
unique
Basis Function Combinator
Given a list remove duplicate items.
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
unit
Basis Function Combinator
(a1 -- [a1 ])
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
unquoted
Basis Function Combinator
i
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
unswons
Basis Function Combinator
([a1 ...1] -- [...1] a1)
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
void
Basis Function Combinator
True if the form on TOS is void otherwise False.
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
warranty
Basis Function Combinator
Print warranty information.
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
while
Basis Function Combinator
swap nulco dupdipd concat loop
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
words
Basis Function Combinator
Print all the words in alphabetical order.
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
x
(Combinator)
[F] x
-----------
[F] F
Definition
dup i
Discussion
The x combinator ...
xor
Basis Function Combinator
Same as a ^ b.
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis
Discussion
Crosslinks
zip
Basis Function Combinator
Replace the two lists on the top of the stack with a list of the pairs from each list. The smallest list sets the length of the result list.
Gentzen diagram.
Definition
if not basis.
Derivation
if not basis.
Source
if basis