And there are the P's.

This commit is contained in:
Simon Forman 2022-03-27 13:04:42 -07:00
parent fb2cdff6b9
commit 4613d6a0a8
15 changed files with 707 additions and 950 deletions

File diff suppressed because it is too large Load Diff

View File

@ -2479,31 +2479,31 @@ A fine old word from Forth.
## pam ## pam
Basis Function Combinator Combinator
\[i\] map Take a list of quoted functions from the stack and replace it with a list
of the [first] results from running those functions (on copies of the
rest of the stack.)
Gentzen diagram. ### Example
5 7 [[+][-][*][/][%]] pam
-------------------------------
5 7 [12 -2 35 0 5]
### Definition ### Definition
if not basis. > \[[i]\] [map]
### Derivation
if not basis.
### Source
if basis
### Discussion ### Discussion
Lorem ipsum. A specialization of [map] that runs a list of functions in parallel (if
the underlying [map] function is so implemented, of course.)
### Crosslinks ### Crosslinks
Lorem ipsum. [map]
-------------- --------------
@ -2516,392 +2516,292 @@ See [getitem](#getitem).
## pm ## pm
Basis Function Combinator Function
Plus or minus : Plus or minus. Replace two numbers with their sum and difference.
a b pm a b pm
------------- -----------------
a+b a-b (a+b) (a-b)
Gentzen diagram.
### Definition ### Definition
if not basis. > \[+\] \[-\] [clop]
### Derivation
if not basis.
### Source
if basis
### Discussion
Lorem ipsum.
### Crosslinks
Lorem ipsum.
------------------------------------------------------------------------ ------------------------------------------------------------------------
## pop ## pop
Basis Function Combinator Basis Function
(a1 --) Pop the top item from the stack and discard it.
Gentzen diagram. a pop
-----------
### Definition
if not basis.
### Derivation
if not basis.
### Source
if basis
### Discussion
Lorem ipsum.
### Crosslinks ### Crosslinks
Lorem ipsum. [popd]
[popdd]
[popop]
[popopd]
[popopdd]
[popopop]
------------------------------------------------------------------------ ------------------------------------------------------------------------
## popd ## popd
Basis Function Combinator Function
(a2 a1 -- a1) [pop] the second item down on the stack.
Gentzen diagram. a b popd
--------------
b
### Definition ### Definition
if not basis. > [swap] [pop]
### Derivation
if not basis.
### Source
if basis
### Discussion
Lorem ipsum.
### Crosslinks ### Crosslinks
Lorem ipsum. [pop]
[popdd]
[popop]
[popopd]
[popopdd]
[popopop]
------------------------------------------------------------------------ ------------------------------------------------------------------------
## popdd ## popdd
Basis Function Combinator Function
(a3 a2 a1 -- a2 a1) [pop] the third item on the stack.
Gentzen diagram. a b c popdd
-----------------
b c
### Definition ### Definition
if not basis. > [rolldown] [pop]
### Derivation
if not basis.
### Source
if basis
### Discussion
Lorem ipsum.
### Crosslinks ### Crosslinks
Lorem ipsum. [pop]
[popd]
[popop]
[popopd]
[popopdd]
[popopop]
------------------------------------------------------------------------ ------------------------------------------------------------------------
## popop ## popop
Basis Function Combinator Function
(a2 a1 --) [pop] two items from the stack.
Gentzen diagram. a b popop
---------------
### Definition ### Definition
if not basis. > [pop] [pop]
### Derivation
if not basis.
### Source
if basis
### Discussion
Lorem ipsum.
### Crosslinks ### Crosslinks
Lorem ipsum. [pop]
[popd]
[popdd]
[popopd]
[popopdd]
[popopop]
------------------------------------------------------------------------ ------------------------------------------------------------------------
## popopd ## popopd
Basis Function Combinator Function
(a3 a2 a1 -- a1) [pop] the second and third items from the stack.
Gentzen diagram. a b c popopd
------------------
c
### Definition ### Definition
if not basis. > [rollup] [popop]
### Derivation
if not basis.
### Source
if basis
### Discussion
Lorem ipsum.
### Crosslinks ### Crosslinks
Lorem ipsum. [pop]
[popd]
[popdd]
[popop]
[popopdd]
[popopop]
------------------------------------------------------------------------ ------------------------------------------------------------------------
## popopdd ## popopdd
Basis Function Combinator Function
(a4 a3 a2 a1 -- a2 a1) a b c d popopdd
---------------------
Gentzen diagram. c d
### Definition ### Definition
if not basis. > \[[popop]\] [dipd]
### Derivation
if not basis.
### Source
if basis
### Discussion
Lorem ipsum.
### Crosslinks ### Crosslinks
Lorem ipsum. [pop]
[popd]
[popdd]
[popop]
[popopd]
[popopop]
------------------------------------------------------------------------ ------------------------------------------------------------------------
## popopop ## popopop
Basis Function Combinator Function
pop popop [pop] three items from the stack.
Gentzen diagram. a b c popopop
-------------------
### Definition ### Definition
if not basis. > [pop] [popop]
### Derivation
if not basis.
### Source
if basis
### Discussion
Lorem ipsum.
### Crosslinks ### Crosslinks
Lorem ipsum. [pop]
[popd]
[popdd]
[popop]
[popopd]
[popopdd]
------------------------------------------------------------------------ ------------------------------------------------------------------------
## pow ## pow
Basis Function Combinator Basis Function
Same as a \*\* b. Take two numbers `a` and `b` from the stack and raise `a` to the `n`th
power. (`b` is on the top of the stack.)
Gentzen diagram. a n pow
-------------
(aⁿ)
### Definition ### Example
if not basis. 2 [2 3 4 5 6 7 8 9] [pow] map
-----------------------------------
2 [4 8 16 32 64 128 256 512]
### Derivation
if not basis.
### Source
if basis
### Discussion
Lorem ipsum.
### Crosslinks
Lorem ipsum.
------------------------------------------------------------------------ ------------------------------------------------------------------------
## pred ## pred
Basis Function Combinator Function
Decrement TOS. Predecessor. Decrement TOS.
Gentzen diagram.
### Definition ### Definition
if not basis. > 1 -
### Derivation
if not basis.
### Source
if basis
### Discussion
Lorem ipsum.
### Crosslinks ### Crosslinks
Lorem ipsum. [succ]
------------------------------------------------------------------------ ------------------------------------------------------------------------
## primrec ## primrec
Basis Function Combinator Combinator
From the \"Overview of the language JOY\": From the ["Overview of the language JOY"](https://www.kevinalbrecht.com/code/joy-mirror/j00ovr.html)
\> The primrec combinator expects two quoted programs in addition to a > 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. For an integer data parameter it works like this: If
data parameter is zero, then the first quotation has to produce the > 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 > 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 > has to combine the data parameter with the result of applying the
function to its predecessor.: > function to its predecessor.
5 [1] [*] primrec > 5 \[1\] \[\*\] primrec
\> Then primrec tests whether the top element on the stack (initially > Then primrec tests whether the top element on the stack (initially the
the 5) is equal to zero. If it is, it pops it off and executes one of > 5) is equal to zero. If it is, it pops it off and executes one of the
the quotations, the \[1\] which leaves 1 on the stack as the result. > quotations, the \[1\] which leaves 1 on the stack as the result.
Otherwise it pushes a decremented copy of the top element and recurses. > Otherwise it pushes a decremented copy of the top element and recurses.
On the way back from the recursion it uses the other quotation, \[\*\], > 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 > to multiply what is now a factorial on top of the stack by the second
element on the stack.: > element on the stack.
n [Base] [Recur] primrec
0 [Base] [Recur] primrec 0 [Base] [Recur] primrec
------------------------------ ------------------------------
Base Base
n [Base] [Recur] primrec n [Base] [Recur] primrec
------------------------------------------ n > 0 ------------------------------------------ n > 0
n (n-1) [Base] [Recur] primrec Recur n (n-1) [Base] [Recur] primrec Recur
Gentzen diagram.
### Definition
if not basis.
### Derivation
if not basis.
### Source
if basis
### Discussion ### Discussion
Lorem ipsum. Simple and useful specialization of the [genrec] combinator from the
[original Joy system](https://www.kevinalbrecht.com/code/joy-mirror/index.html).
### Crosslinks ### Crosslinks
Lorem ipsum. [genrec]
[tailrec]
------------------------------------------------------------------------ ------------------------------------------------------------------------
## product ## product
Basis Function Combinator Function
1 swap \[\*\] step Just as [sum] sums a list of numbers, this function multiplies them
together.
Gentzen diagram.
### Definition ### Definition
if not basis. > 1 [swap] \[[mul]\] [step]
### Derivation Or,
if not basis. > \[1\] \[[mul]\] [primrec]
### Source
if basis
### Discussion
Lorem ipsum.
### Crosslinks
Lorem ipsum.
------------------------------------------------------------------------ ------------------------------------------------------------------------

View File

@ -2,28 +2,28 @@
## pam ## pam
Basis Function Combinator Combinator
\[i\] map Take a list of quoted functions from the stack and replace it with a list
of the [first] results from running those functions (on copies of the
rest of the stack.)
Gentzen diagram. ### Example
5 7 [[+][-][*][/][%]] pam
-------------------------------
5 7 [12 -2 35 0 5]
### Definition ### Definition
if not basis. > \[[i]\] [map]
### Derivation
if not basis.
### Source
if basis
### Discussion ### Discussion
Lorem ipsum. A specialization of [map] that runs a list of functions in parallel (if
the underlying [map] function is so implemented, of course.)
### Crosslinks ### Crosslinks
Lorem ipsum. [map]

View File

@ -2,32 +2,15 @@
## pm ## pm
Basis Function Combinator Function
Plus or minus : Plus or minus. Replace two numbers with their sum and difference.
a b pm a b pm
------------- -----------------
a+b a-b (a+b) (a-b)
Gentzen diagram.
### Definition ### Definition
if not basis. > \[+\] \[-\] [clop]
### Derivation
if not basis.
### Source
if basis
### Discussion
Lorem ipsum.
### Crosslinks
Lorem ipsum.

View File

@ -2,28 +2,19 @@
## pop ## pop
Basis Function Combinator Basis Function
(a1 --) Pop the top item from the stack and discard it.
Gentzen diagram. a pop
-----------
### Definition
if not basis.
### Derivation
if not basis.
### Source
if basis
### Discussion
Lorem ipsum.
### Crosslinks ### Crosslinks
Lorem ipsum. [popd]
[popdd]
[popop]
[popopd]
[popopdd]
[popopop]

View File

@ -2,28 +2,24 @@
## popd ## popd
Basis Function Combinator Function
(a2 a1 -- a1) [pop] the second item down on the stack.
Gentzen diagram. a b popd
--------------
b
### Definition ### Definition
if not basis. > [swap] [pop]
### Derivation
if not basis.
### Source
if basis
### Discussion
Lorem ipsum.
### Crosslinks ### Crosslinks
Lorem ipsum. [pop]
[popdd]
[popop]
[popopd]
[popopdd]
[popopop]

View File

@ -2,28 +2,24 @@
## popdd ## popdd
Basis Function Combinator Function
(a3 a2 a1 -- a2 a1) [pop] the third item on the stack.
Gentzen diagram. a b c popdd
-----------------
b c
### Definition ### Definition
if not basis. > [rolldown] [pop]
### Derivation
if not basis.
### Source
if basis
### Discussion
Lorem ipsum.
### Crosslinks ### Crosslinks
Lorem ipsum. [pop]
[popd]
[popop]
[popopd]
[popopdd]
[popopop]

View File

@ -2,28 +2,23 @@
## popop ## popop
Basis Function Combinator Function
(a2 a1 --) [pop] two items from the stack.
Gentzen diagram. a b popop
---------------
### Definition ### Definition
if not basis. > [pop] [pop]
### Derivation
if not basis.
### Source
if basis
### Discussion
Lorem ipsum.
### Crosslinks ### Crosslinks
Lorem ipsum. [pop]
[popd]
[popdd]
[popopd]
[popopdd]
[popopop]

View File

@ -2,28 +2,24 @@
## popopd ## popopd
Basis Function Combinator Function
(a3 a2 a1 -- a1) [pop] the second and third items from the stack.
Gentzen diagram. a b c popopd
------------------
c
### Definition ### Definition
if not basis. > [rollup] [popop]
### Derivation
if not basis.
### Source
if basis
### Discussion
Lorem ipsum.
### Crosslinks ### Crosslinks
Lorem ipsum. [pop]
[popd]
[popdd]
[popop]
[popopdd]
[popopop]

View File

@ -2,28 +2,22 @@
## popopdd ## popopdd
Basis Function Combinator Function
(a4 a3 a2 a1 -- a2 a1) a b c d popopdd
---------------------
Gentzen diagram. c d
### Definition ### Definition
if not basis. > \[[popop]\] [dipd]
### Derivation
if not basis.
### Source
if basis
### Discussion
Lorem ipsum.
### Crosslinks ### Crosslinks
Lorem ipsum. [pop]
[popd]
[popdd]
[popop]
[popopd]
[popopop]

View File

@ -2,28 +2,23 @@
## popopop ## popopop
Basis Function Combinator Function
pop popop [pop] three items from the stack.
Gentzen diagram. a b c popopop
-------------------
### Definition ### Definition
if not basis. > [pop] [popop]
### Derivation
if not basis.
### Source
if basis
### Discussion
Lorem ipsum.
### Crosslinks ### Crosslinks
Lorem ipsum. [pop]
[popd]
[popdd]
[popop]
[popopd]
[popopdd]

View File

@ -2,28 +2,18 @@
## pow ## pow
Basis Function Combinator Basis Function
Same as a \*\* b. Take two numbers `a` and `b` from the stack and raise `a` to the `n`th
power. (`b` is on the top of the stack.)
Gentzen diagram. a n pow
-------------
(aⁿ)
### Definition ### Example
if not basis. 2 [2 3 4 5 6 7 8 9] [pow] map
-----------------------------------
2 [4 8 16 32 64 128 256 512]
### Derivation
if not basis.
### Source
if basis
### Discussion
Lorem ipsum.
### Crosslinks
Lorem ipsum.

View File

@ -2,28 +2,15 @@
## pred ## pred
Basis Function Combinator Function
Decrement TOS. Predecessor. Decrement TOS.
Gentzen diagram.
### Definition ### Definition
if not basis. > 1 -
### Derivation
if not basis.
### Source
if basis
### Discussion
Lorem ipsum.
### Crosslinks ### Crosslinks
Lorem ipsum. [succ]

View File

@ -2,55 +2,43 @@
## primrec ## primrec
Basis Function Combinator Combinator
From the \"Overview of the language JOY\": From the ["Overview of the language JOY"](https://www.kevinalbrecht.com/code/joy-mirror/j00ovr.html)
\> The primrec combinator expects two quoted programs in addition to a > 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. For an integer data parameter it works like this: If
data parameter is zero, then the first quotation has to produce the > 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 > 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 > has to combine the data parameter with the result of applying the
function to its predecessor.: > function to its predecessor.
5 [1] [*] primrec > 5 \[1\] \[\*\] primrec
\> Then primrec tests whether the top element on the stack (initially > Then primrec tests whether the top element on the stack (initially the
the 5) is equal to zero. If it is, it pops it off and executes one of > 5) is equal to zero. If it is, it pops it off and executes one of the
the quotations, the \[1\] which leaves 1 on the stack as the result. > quotations, the \[1\] which leaves 1 on the stack as the result.
Otherwise it pushes a decremented copy of the top element and recurses. > Otherwise it pushes a decremented copy of the top element and recurses.
On the way back from the recursion it uses the other quotation, \[\*\], > 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 > to multiply what is now a factorial on top of the stack by the second
element on the stack.: > element on the stack.
n [Base] [Recur] primrec
0 [Base] [Recur] primrec 0 [Base] [Recur] primrec
------------------------------ ------------------------------
Base Base
n [Base] [Recur] primrec n [Base] [Recur] primrec
------------------------------------------ n > 0 ------------------------------------------ n > 0
n (n-1) [Base] [Recur] primrec Recur n (n-1) [Base] [Recur] primrec Recur
Gentzen diagram.
### Definition
if not basis.
### Derivation
if not basis.
### Source
if basis
### Discussion ### Discussion
Lorem ipsum. Simple and useful specialization of the [genrec] combinator from the
[original Joy system](https://www.kevinalbrecht.com/code/joy-mirror/index.html).
### Crosslinks ### Crosslinks
Lorem ipsum. [genrec]
[tailrec]

View File

@ -2,28 +2,17 @@
## product ## product
Basis Function Combinator Function
1 swap \[\*\] step Just as [sum] sums a list of numbers, this function multiplies them
together.
Gentzen diagram.
### Definition ### Definition
if not basis. > 1 [swap] \[[mul]\] [step]
### Derivation Or,
if not basis. > \[1\] \[[mul]\] [primrec]
### Source
if basis
### Discussion
Lorem ipsum.
### Crosslinks
Lorem ipsum.