From: Simon Forman Date: Fri, 25 Mar 2022 19:39:03 +0000 (-0700) Subject: Most of the G's. X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=463d7eb9ae4749918de400d5e7e9381798d11713;p=joypy%2FThun.git Most of the G's. --- diff --git a/docs/reference/eq.md b/docs/reference/eq.md index 7340fb9..26ef0c7 100644 --- a/docs/reference/eq.md +++ b/docs/reference/eq.md @@ -10,10 +10,7 @@ them with a Boolean value. a b eq ------------- Boolean - -### Discussion - -Lorem ipsum. + (a = b) ### Crosslinks diff --git a/docs/reference/gcd.md b/docs/reference/gcd.md index b9f812a..625d534 100644 --- a/docs/reference/gcd.md +++ b/docs/reference/gcd.md @@ -2,28 +2,16 @@ ## gcd -Basis Function Combinator +Function -true \[tuck mod dup 0 \>\] loop pop - -Gentzen diagram. +Take two integers from the stack and replace them with their Greatest +Common Denominator. ### Definition -if not basis. - -### Derivation - -if not basis. - -### Source - -if basis +> true \[[tuck] [mod] [dup] 0 [>]\] [loop] [pop] ### Discussion -Lorem ipsum. - -### Crosslinks +Euclid's Algorithm -Lorem ipsum. diff --git a/docs/reference/gcd2.md b/docs/reference/gcd2.md index c640544..30d8598 100644 --- a/docs/reference/gcd2.md +++ b/docs/reference/gcd2.md @@ -2,28 +2,15 @@ ## gcd2 -Basis Function Combinator +Function Compiled GCD function. -Gentzen diagram. - -### Definition - -if not basis. - -### Derivation - -if not basis. - -### Source - -if basis - ### Discussion -Lorem ipsum. +See [gcd]. ### Crosslinks -Lorem ipsum. +[gcd] + diff --git a/docs/reference/ge.md b/docs/reference/ge.md index 7c26c7a..c46afd0 100644 --- a/docs/reference/ge.md +++ b/docs/reference/ge.md @@ -2,28 +2,22 @@ ## ge -Basis Function Combinator +Basis Function -Same as a \>= b. +Greater-than-or-equal-to comparison of two numbers. -Gentzen diagram. + a b ge + -------------- + Boolean + (a >= b) -### Definition - -if not basis. - -### Derivation - -if not basis. - -### Source - -if basis - -### Discussion - -Lorem ipsum. ### Crosslinks -Lorem ipsum. +[cmp] +[eq] +[gt] +[le] +[lt] +[ne] + diff --git a/docs/reference/genrec.md b/docs/reference/genrec.md index 917fffd..3104791 100644 --- a/docs/reference/genrec.md +++ b/docs/reference/genrec.md @@ -2,70 +2,70 @@ ## genrec -Basis Function Combinator +Combinator -General Recursion Combinator. : +**Gen**eral **Rec**ursion Combinator. - [if] [then] [rec1] [rec2] genrec + [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\': : + [if] [then] [rec1 [[if] [then] [rec1] [rec2] genrec] rec2] ifte - F == [I] [T] [R1] [R2] genrec +### Definition -If the \[I\] if-part fails you must derive R1 and R2 from: : +> \[\[[genrec]\] [ccccons]\] [nullary] [swons] [concat] [ifte] - ... R1 [F] R2 +(Note that this definition includes the `genrec` symbol itself, it is +self-referential. This is possible because the definition machinery does +not check that symbols in defs are in the dictionary. `genrec` is the +only self-referential definition.) -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: : +### Discussion - F == [I] [T] [R1] [R2] genrec - == [I] [T] [R1 [F] R2] ifte +See the [Recursion Combinators notebook](https://joypy.osdn.io/notebooks/Recursion_Combinators.html). -Primitive recursive functions are those where R2 == i. : +From ["Recursion Theory and Joy"](https://www.kevinalbrecht.com/code/joy-mirror/j05cmp.html) +by Manfred von Thun: - P == [I] [T] [R] tailrec - == [I] [T] [R [P] i] ifte - == [I] [T] [R P] ifte +> "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." -Gentzen diagram. +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. -### Definition +For example, given a (general recursive) function `F`: -if not basis. + F == [I] [T] [R1] [R2] genrec -### Derivation +If the `[I]` if-part fails you must derive `R1` and `R2` from: : -if not basis. + ... R1 [F] R2 -### Source +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: -if basis + F == [I] [T] [R1] [R2] genrec + == [I] [T] [R1 [F] R2] ifte -### Discussion +Tail recursive functions are those where `R2` is the `i` combinator: -Lorem ipsum. + P == [I] [T] [R] tailrec + == [I] [T] [R [P] i] ifte + == [I] [T] [R P] ifte ### Crosslinks -Lorem ipsum. +[anamorphism] +[tailrec] +[x] + diff --git a/docs/reference/getitem.md b/docs/reference/getitem.md index 446dd9f..7725ee0 100644 --- a/docs/reference/getitem.md +++ b/docs/reference/getitem.md @@ -2,35 +2,45 @@ ## getitem -Basis Function Combinator - - getitem == drop first +Function Expects an integer and a quote on the stack and returns the item at the -nth position in the quote counting from 0. : +nth position in the quote counting from 0. - [a b c d] 0 getitem - ------------------------- - a +### Example -Gentzen diagram. + [a b c d] 2 getitem + ------------------------- + c ### Definition -if not basis. - -### Derivation - -if not basis. - -### Source - -if basis +> [drop] [first] ### Discussion -Lorem ipsum. +If the number isn't a valid index into the quote `getitem` will cause +some sort of problem (the exact nature of which is +implementation-dependant.) ### Crosslinks -Lorem ipsum. +[concat] +[first] +[first_two] +[flatten] +[fourth] +[remove] +[rest] +[reverse] +[rrest] +[second] +[shift] +[shunt] +[size] +[sort] +[split_at] +[split_list] +[swaack] +[third] +[zip] diff --git a/docs/reference/grabN.md b/docs/reference/grabN.md index be3b6d6..78ab208 100644 --- a/docs/reference/grabN.md +++ b/docs/reference/grabN.md @@ -2,7 +2,7 @@ ## grabN -Basis Function Combinator +Function \<{} \[cons\] times diff --git a/docs/reference/mkref/FuncRef.html b/docs/reference/mkref/FuncRef.html index 8625611..d4441b0 100644 --- a/docs/reference/mkref/FuncRef.html +++ b/docs/reference/mkref/FuncRef.html @@ -1055,9 +1055,8 @@ a F a

Compare the two items on the top of the stack for equality and replace them with a Boolean value.

   a b eq
 -------------
-   Boolean
-

Discussion

-

Lorem ipsum.

+ Boolean + (a = b)

cmp ge gt le lt ne


@@ -1098,7 +1097,7 @@ a F a

<{} [concat] step

-

Discussion

+

Discussion

Note that only one “level” of lists is flattened. In the example above [4] is not unquoted.

concat first first_two fourth getitem remove rest reverse rrest second shift shunt size sort split_at split_list swaack third zip

@@ -1106,7 +1105,7 @@ a F a

floor

Basis Function

Return the largest integer <= x.

-

Discussion

+

Discussion

This function doesn’t make sense (yet) to have because there are (as yet) only integers in the system.


floordiv

@@ -1115,7 +1114,7 @@ a F a
   a b floordiv
 ------------------
       (a/b)
-

Discussion

+

Discussion

All the division commands need to be revisited when the “numeric tower” for Thun gets nailed down.

divmod

@@ -1130,7 +1129,7 @@ a F a

[i] app2

-

Discussion

+

Discussion

The basic parallelism combinator, the two programs are run independently.

cleave clop map

@@ -1149,173 +1148,154 @@ a F a

first second third rest


gcd

-

Basis Function Combinator

-

true [tuck mod dup 0 >] loop pop

-

Gentzen diagram.

+

Function

+

Take two integers from the stack and replace them with their Greatest Common Denominator.

Definition

-

if not basis.

-

Derivation

-

if not basis.

-

Source

-

if basis

-

Discussion

-

Lorem ipsum.

- -

Lorem ipsum.

+
+

true [tuck mod dup 0 >] loop pop

+
+

Discussion

+

Euclid’s Algorithm


gcd2

-

Basis Function Combinator

+

Function

Compiled GCD function.

-

Gentzen diagram.

-

Definition

-

if not basis.

-

Derivation

-

if not basis.

-

Source

-

if basis

-

Discussion

-

Lorem ipsum.

- -

Lorem ipsum.

+

Discussion

+

See gcd.

+ +

gcd


ge

-

Basis Function Combinator

-

Same as a >= b.

-

Gentzen diagram.

-

Definition

-

if not basis.

-

Derivation

-

if not basis.

-

Source

-

if basis

-

Discussion

-

Lorem ipsum.

- -

Lorem ipsum.

+

Basis Function

+

Greater-than-or-equal-to comparison of two numbers.

+
   a b ge
+--------------
+   Boolean
+   (a >= b)
+ +

cmp eq gt le lt ne


genrec

-

Basis Function Combinator

-

General Recursion Combinator. :

-
[if] [then] [rec1] [rec2] genrec
+

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': :

+ [if] [then] [rec1 [[if] [then] [rec1] [rec2] genrec] rec2] ifte
+

Definition

+
+

[[genrec] ccccons] nullary swons concat ifte

+
+

(Note that this definition includes the genrec symbol itself, it is self-referential. This is possible because the definition machinery does not check that symbols in defs are in the dictionary. genrec is the only self-referential definition.)

+

Discussion

+

See the Recursion Combinators notebook.

+

From “Recursion Theory and Joy” 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: :

+

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: :

+

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. :

+

Tail recursive functions are those where R2 is the i combinator:

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

-

Lorem ipsum.

- -

Lorem ipsum.

+ +

anamorphism tailrec x


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
+

Function

+

Expects an integer and a quote on the stack and returns the item at the nth position in the quote counting from 0.

+

Example

+
   [a b c d] 2 getitem
 -------------------------
- a
-

Gentzen diagram.

-

Definition

-

if not basis.

-

Derivation

-

if not basis.

-

Source

-

if basis

-

Discussion

-

Lorem ipsum.

- -

Lorem ipsum.

+ c
+

Definition

+
+

drop first

+
+

Discussion

+

If the number isn’t a valid index into the quote getitem will cause some sort of problem (the exact nature of which is implementation-dependant.)

+ +

concat first first_two flatten fourth remove rest reverse rrest second shift shunt size sort split_at split_list swaack third zip


grabN

Basis Function Combinator

<{} [cons] times

Gentzen diagram.

-

Definition

+

Definition

if not basis.

-

Derivation

+

Derivation

if not basis.

-

Source

+

Source

if basis

-

Discussion

+

Discussion

Lorem ipsum.

- +

Lorem ipsum.


grba

Basis Function Combinator

[stack popd] dip

Gentzen diagram.

-

Definition

+

Definition

if not basis.

-

Derivation

+

Derivation

if not basis.

-

Source

+

Source

if basis

-

Discussion

+

Discussion

Lorem ipsum.

- +

Lorem ipsum.


gt

Basis Function Combinator

Same as a > b.

Gentzen diagram.

-

Definition

+

Definition

if not basis.

-

Derivation

+

Derivation

if not basis.

-

Source

+

Source

if basis

-

Discussion

+

Discussion

Lorem ipsum.

- +

Lorem ipsum.


help

Basis Function Combinator

Accepts a quoted symbol on the top of the stack and prints its docs.

Gentzen diagram.

-

Definition

+

Definition

if not basis.

-

Derivation

+

Derivation

if not basis.

-

Source

+

Source

if basis

-

Discussion

+

Discussion

Lorem ipsum.

- +

Lorem ipsum.


hypot

Basis Function Combinator

[sqr] ii + sqrt

Gentzen diagram.

-

Definition

+

Definition

if not basis.

-

Derivation

+

Derivation

if not basis.

-

Source

+

Source

if basis

-

Discussion

+

Discussion

Lorem ipsum.

- +

Lorem ipsum.


i

@@ -1324,24 +1304,24 @@ a F a
   [Q] i
 -----------
     Q
-

Source

+

Source

combo(i, [list(P)|S], S, Ei, Eo) :- append(P, Ei, Eo).
-

Discussion

+

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

+

Definition

if not basis.

-

Derivation

+

Derivation

if not basis.

-

Source

+

Source

if basis

-

Discussion

+

Discussion

Lorem ipsum.

- +

Lorem ipsum.


ifte

@@ -1359,15 +1339,15 @@ a F a ... [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

+

Definition

if not basis.

-

Derivation

+

Derivation

if not basis.

-

Source

+

Source

if basis

-

Discussion

+

Discussion

Lorem ipsum.

- +

Lorem ipsum.


ii

@@ -1376,15 +1356,15 @@ a F a ------------------ ... Q a Q

Gentzen diagram.

-

Definition

+

Definition

if not basis.

-

Derivation

+

Derivation

if not basis.

-

Source

+

Source

if basis

-

Discussion

+

Discussion

Lorem ipsum.

- +

Lorem ipsum.


infra

@@ -1393,26 +1373,26 @@ a F a
   ... [a b c] [Q] infra
 ---------------------------
     c b a Q [...] swaack
-

Definition

+

Definition

swons swaack [i] dip swaack
-

Discussion

+

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.

- +

swaack


infrst

Basis Function Combinator

infra first

Gentzen diagram.

-

Definition

+

Definition

if not basis.

-

Derivation

+

Derivation

if not basis.

-

Source

+

Source

if basis

-

Discussion

+

Discussion

Lorem ipsum.

- +

Lorem ipsum.


inscribe

@@ -1422,30 +1402,30 @@ a F a

[sqr dup mul] inscribe

Gentzen diagram.

-

Definition

+

Definition

if not basis.

-

Derivation

+

Derivation

if not basis.

-

Source

+

Source

if basis

-

Discussion

+

Discussion

Lorem ipsum.

- +

Lorem ipsum.


le

Basis Function Combinator

Same as a <= b.

Gentzen diagram.

-

Definition

+

Definition

if not basis.

-

Derivation

+

Derivation

if not basis.

-

Source

+

Source

if basis

-

Discussion

+

Discussion

Lorem ipsum.

- +

Lorem ipsum.


loop

@@ -1459,120 +1439,120 @@ a F a ------------------------ ...

Gentzen diagram.

-

Definition

+

Definition

if not basis.

-

Derivation

+

Derivation

if not basis.

-

Source

+

Source

if basis

-

Discussion

+

Discussion

Lorem ipsum.

- +

Lorem ipsum.


lshift

Basis Function Combinator

Same as a << b.

Gentzen diagram.

-

Definition

+

Definition

if not basis.

-

Derivation

+

Derivation

if not basis.

-

Source

+

Source

if basis

-

Discussion

+

Discussion

Lorem ipsum.

- +

Lorem ipsum.


lt

Basis Function Combinator

Same as a < b.

Gentzen diagram.

-

Definition

+

Definition

if not basis.

-

Derivation

+

Derivation

if not basis.

-

Source

+

Source

if basis

-

Discussion

+

Discussion

Lorem ipsum.

- +

Lorem ipsum.


make_generator

Basis Function Combinator

[codireco] ccons

Gentzen diagram.

-

Definition

+

Definition

if not basis.

-

Derivation

+

Derivation

if not basis.

-

Source

+

Source

if basis

-

Discussion

+

Discussion

Lorem ipsum.

- +

Lorem ipsum.


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

+

Definition

if not basis.

-

Derivation

+

Derivation

if not basis.

-

Source

+

Source

if basis

-

Discussion

+

Discussion

Lorem ipsum.

- +

Lorem ipsum.


max

Basis Function Combinator

Given a list find the maximum.

Gentzen diagram.

-

Definition

+

Definition

if not basis.

-

Derivation

+

Derivation

if not basis.

-

Source

+

Source

if basis

-

Discussion

+

Discussion

Lorem ipsum.

- +

Lorem ipsum.


min

Basis Function Combinator

Given a list find the minimum.

Gentzen diagram.

-

Definition

+

Definition

if not basis.

-

Derivation

+

Derivation

if not basis.

-

Source

+

Source

if basis

-

Discussion

+

Discussion

Lorem ipsum.

- +

Lorem ipsum.


mod

Basis Function Combinator

Same as a % b.

Gentzen diagram.

-

Definition

+

Definition

if not basis.

-

Derivation

+

Derivation

if not basis.

-

Source

+

Source

if basis

-

Discussion

+

Discussion

Lorem ipsum.

- +

Lorem ipsum.


modulus

@@ -1582,60 +1562,60 @@ a F a

Basis Function Combinator

Same as a * b.

Gentzen diagram.

-

Definition

+

Definition

if not basis.

-

Derivation

+

Derivation

if not basis.

-

Source

+

Source

if basis

-

Discussion

+

Discussion

Lorem ipsum.

- +

Lorem ipsum.


ne

Basis Function Combinator

Same as a != b.

Gentzen diagram.

-

Definition

+

Definition

if not basis.

-

Derivation

+

Derivation

if not basis.

-

Source

+

Source

if basis

-

Discussion

+

Discussion

Lorem ipsum.

- +

Lorem ipsum.


neg

Basis Function Combinator

Same as -a.

Gentzen diagram.

-

Definition

+

Definition

if not basis.

-

Derivation

+

Derivation

if not basis.

-

Source

+

Source

if basis

-

Discussion

+

Discussion

Lorem ipsum.

- +

Lorem ipsum.


not

Basis Function Combinator

Same as not a.

Gentzen diagram.

-

Definition

+

Definition

if not basis.

-

Derivation

+

Derivation

if not basis.

-

Source

+

Source

if basis

-

Discussion

+

Discussion

Lorem ipsum.

- +

Lorem ipsum.


!-

@@ -1649,22 +1629,22 @@ a F a N !- ---------- N >= 0 true -

Definition

+

Definition

0 >=

nulco

Basis Function Combinator

[nullary] cons

Gentzen diagram.

-

Definition

+

Definition

if not basis.

-

Derivation

+

Derivation

if not basis.

-

Source

+

Source

if basis

-

Discussion

+

Discussion

Lorem ipsum.

- +

Lorem ipsum.


nullary

@@ -1673,78 +1653,78 @@ a F a
   ... [P] nullary
 ---------------------
         ... A
-

Definition

+

Definition

[stack] dip infra first
-

Derivation

+

Derivation

... [P] nullary
 ... [P] [stack] dip infra first
 ... stack [P] infra first
 ... [...] [P] infra first
 ... [A ...] first
 ...  A
-

Discussion

+

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.)

- +

unary binary ternary


of

Basis Function Combinator

swap at

Gentzen diagram.

-

Definition

+

Definition

if not basis.

-

Derivation

+

Derivation

if not basis.

-

Source

+

Source

if basis

-

Discussion

+

Discussion

Lorem ipsum.

- +

Lorem ipsum.


or

Basis Function Combinator

Same as a | b.

Gentzen diagram.

-

Definition

+

Definition

if not basis.

-

Derivation

+

Derivation

if not basis.

-

Source

+

Source

if basis

-

Discussion

+

Discussion

Lorem ipsum.

- +

Lorem ipsum.


over

Basis Function Combinator

(a2 a1 -- a2 a1 a2)

Gentzen diagram.

-

Definition

+

Definition

if not basis.

-

Derivation

+

Derivation

if not basis.

-

Source

+

Source

if basis

-

Discussion

+

Discussion

Lorem ipsum.

- +

Lorem ipsum.


pam

Basis Function Combinator

[i] map

Gentzen diagram.

-

Definition

+

Definition

if not basis.

-

Derivation

+

Derivation

if not basis.

-

Source

+

Source

if basis

-

Discussion

+

Discussion

Lorem ipsum.

- +

Lorem ipsum.


pick

@@ -1757,150 +1737,150 @@ a F a ------------- a+b a-b

Gentzen diagram.

-

Definition

+

Definition

if not basis.

-

Derivation

+

Derivation

if not basis.

-

Source

+

Source

if basis

-

Discussion

+

Discussion

Lorem ipsum.

- +

Lorem ipsum.


pop

Basis Function Combinator

(a1 --)

Gentzen diagram.

-

Definition

+

Definition

if not basis.

-

Derivation

+

Derivation

if not basis.

-

Source

+

Source

if basis

-

Discussion

+

Discussion

Lorem ipsum.

- +

Lorem ipsum.


popd

Basis Function Combinator

(a2 a1 -- a1)

Gentzen diagram.

-

Definition

+

Definition

if not basis.

-

Derivation

+

Derivation

if not basis.

-

Source

+

Source

if basis

-

Discussion

+

Discussion

Lorem ipsum.

- +

Lorem ipsum.


popdd

Basis Function Combinator

(a3 a2 a1 -- a2 a1)

Gentzen diagram.

-

Definition

+

Definition

if not basis.

-

Derivation

+

Derivation

if not basis.

-

Source

+

Source

if basis

-

Discussion

+

Discussion

Lorem ipsum.

- +

Lorem ipsum.


popop

Basis Function Combinator

(a2 a1 --)

Gentzen diagram.

-

Definition

+

Definition

if not basis.

-

Derivation

+

Derivation

if not basis.

-

Source

+

Source

if basis

-

Discussion

+

Discussion

Lorem ipsum.

- +

Lorem ipsum.


popopd

Basis Function Combinator

(a3 a2 a1 -- a1)

Gentzen diagram.

-

Definition

+

Definition

if not basis.

-

Derivation

+

Derivation

if not basis.

-

Source

+

Source

if basis

-

Discussion

+

Discussion

Lorem ipsum.

- +

Lorem ipsum.


popopdd

Basis Function Combinator

(a4 a3 a2 a1 -- a2 a1)

Gentzen diagram.

-

Definition

+

Definition

if not basis.

-

Derivation

+

Derivation

if not basis.

-

Source

+

Source

if basis

-

Discussion

+

Discussion

Lorem ipsum.

- +

Lorem ipsum.


popopop

Basis Function Combinator

pop popop

Gentzen diagram.

-

Definition

+

Definition

if not basis.

-

Derivation

+

Derivation

if not basis.

-

Source

+

Source

if basis

-

Discussion

+

Discussion

Lorem ipsum.

- +

Lorem ipsum.


pow

Basis Function Combinator

Same as a ** b.

Gentzen diagram.

-

Definition

+

Definition

if not basis.

-

Derivation

+

Derivation

if not basis.

-

Source

+

Source

if basis

-

Discussion

+

Discussion

Lorem ipsum.

- +

Lorem ipsum.


pred

Basis Function Combinator

Decrement TOS.

Gentzen diagram.

-

Definition

+

Definition

if not basis.

-

Derivation

+

Derivation

if not basis.

-

Source

+

Source

if basis

-

Discussion

+

Discussion

Lorem ipsum.

- +

Lorem ipsum.


primrec

@@ -1919,90 +1899,90 @@ a+b a-b ------------------------------------------ n > 0 n (n-1) [Base] [Recur] primrec Recur

Gentzen diagram.

-

Definition

+

Definition

if not basis.

-

Derivation

+

Derivation

if not basis.

-

Source

+

Source

if basis

-

Discussion

+

Discussion

Lorem ipsum.

- +

Lorem ipsum.


product

Basis Function Combinator

1 swap [*] step

Gentzen diagram.

-

Definition

+

Definition

if not basis.

-

Derivation

+

Derivation

if not basis.

-

Source

+

Source

if basis

-

Discussion

+

Discussion

Lorem ipsum.

- +

Lorem ipsum.


quoted

Basis Function Combinator

[unit] dip

Gentzen diagram.

-

Definition

+

Definition

if not basis.

-

Derivation

+

Derivation

if not basis.

-

Source

+

Source

if basis

-

Discussion

+

Discussion

Lorem ipsum.

- +

Lorem ipsum.


range

Basis Function Combinator

[0 <=] [1 - dup] anamorphism

Gentzen diagram.

-

Definition

+

Definition

if not basis.

-

Derivation

+

Derivation

if not basis.

-

Source

+

Source

if basis

-

Discussion

+

Discussion

Lorem ipsum.

- +

Lorem ipsum.


range_to_zero

Basis Function Combinator

unit [down_to_zero] infra

Gentzen diagram.

-

Definition

+

Definition

if not basis.

-

Derivation

+

Derivation

if not basis.

-

Source

+

Source

if basis

-

Discussion

+

Discussion

Lorem ipsum.

- +

Lorem ipsum.


reco

Basis Function Combinator

rest cons

Gentzen diagram.

-

Definition

+

Definition

if not basis.

-

Derivation

+

Derivation

if not basis.

-

Source

+

Source

if basis

-

Discussion

+

Discussion

Lorem ipsum.

- +

Lorem ipsum.


rem

@@ -2018,30 +1998,30 @@ a+b a-b ------------------------ [2 3 1]

Gentzen diagram.

-

Definition

+

Definition

if not basis.

-

Derivation

+

Derivation

if not basis.

-

Source

+

Source

if basis

-

Discussion

+

Discussion

Lorem ipsum.

- +

Lorem ipsum.


rest

Basis Function Combinator

([a1 ...0] -- [...0])

Gentzen diagram.

-

Definition

+

Definition

if not basis.

-

Derivation

+

Derivation

if not basis.

-

Source

+

Source

if basis

-

Discussion

+

Discussion

Lorem ipsum.

- +

Lorem ipsum.


reverse

@@ -2049,45 +2029,45 @@ a+b a-b

Reverse the list on the top of the stack. :

reverse == [] swap shunt

Gentzen diagram.

-

Definition

+

Definition

if not basis.

-

Derivation

+

Derivation

if not basis.

-

Source

+

Source

if basis

-

Discussion

+

Discussion

Lorem ipsum.

- +

Lorem ipsum.


rolldown

Basis Function Combinator

(a1 a2 a3 -- a2 a3 a1)

Gentzen diagram.

-

Definition

+

Definition

if not basis.

-

Derivation

+

Derivation

if not basis.

-

Source

+

Source

if basis

-

Discussion

+

Discussion

Lorem ipsum.

- +

Lorem ipsum.


rollup

Basis Function Combinator

(a1 a2 a3 -- a3 a1 a2)

Gentzen diagram.

-

Definition

+

Definition

if not basis.

-

Derivation

+

Derivation

if not basis.

-

Source

+

Source

if basis

-

Discussion

+

Discussion

Lorem ipsum.

- +

Lorem ipsum.


roll>

@@ -2101,75 +2081,75 @@ a+b a-b

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

+

Definition

if not basis.

-

Derivation

+

Derivation

if not basis.

-

Source

+

Source

if basis

-

Discussion

+

Discussion

Lorem ipsum.

- +

Lorem ipsum.


rrest

Basis Function Combinator

([a1 a2 ...1] -- [...1])

Gentzen diagram.

-

Definition

+

Definition

if not basis.

-

Derivation

+

Derivation

if not basis.

-

Source

+

Source

if basis

-

Discussion

+

Discussion

Lorem ipsum.

- +

Lorem ipsum.


rshift

Basis Function Combinator

Same as a >> b.

Gentzen diagram.

-

Definition

+

Definition

if not basis.

-

Derivation

+

Derivation

if not basis.

-

Source

+

Source

if basis

-

Discussion

+

Discussion

Lorem ipsum.

- +

Lorem ipsum.


run

Basis Function Combinator

<{} infra

Gentzen diagram.

-

Definition

+

Definition

if not basis.

-

Derivation

+

Derivation

if not basis.

-

Source

+

Source

if basis

-

Discussion

+

Discussion

Lorem ipsum.

- +

Lorem ipsum.


second

Basis Function Combinator

([a1 a2 ...1] -- a2)

Gentzen diagram.

-

Definition

+

Definition

if not basis.

-

Derivation

+

Derivation

if not basis.

-

Source

+

Source

if basis

-

Discussion

+

Discussion

Lorem ipsum.

- +

Lorem ipsum.


select

@@ -2185,45 +2165,45 @@ a+b a-b 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

+

Definition

if not basis.

-

Derivation

+

Derivation

if not basis.

-

Source

+

Source

if basis

-

Discussion

+

Discussion

Lorem ipsum.

- +

Lorem ipsum.


sharing

Basis Function Combinator

Print redistribution information.

Gentzen diagram.

-

Definition

+

Definition

if not basis.

-

Derivation

+

Derivation

if not basis.

-

Source

+

Source

if basis

-

Discussion

+

Discussion

Lorem ipsum.

- +

Lorem ipsum.


shift

Basis Function Combinator

uncons [swons] dip

Gentzen diagram.

-

Definition

+

Definition

if not basis.

-

Derivation

+

Derivation

if not basis.

-

Source

+

Source

if basis

-

Discussion

+

Discussion

Lorem ipsum.

- +

Lorem ipsum.


shunt

@@ -2235,150 +2215,150 @@ a+b a-b --------------------------- [f e d a b c]

Gentzen diagram.

-

Definition

+

Definition

if not basis.

-

Derivation

+

Derivation

if not basis.

-

Source

+

Source

if basis

-

Discussion

+

Discussion

Lorem ipsum.

- +

Lorem ipsum.


size

Basis Function Combinator

[pop ++] step_zero

Gentzen diagram.

-

Definition

+

Definition

if not basis.

-

Derivation

+

Derivation

if not basis.

-

Source

+

Source

if basis

-

Discussion

+

Discussion

Lorem ipsum.

- +

Lorem ipsum.


sort

Basis Function Combinator

Given a list return it sorted.

Gentzen diagram.

-

Definition

+

Definition

if not basis.

-

Derivation

+

Derivation

if not basis.

-

Source

+

Source

if basis

-

Discussion

+

Discussion

Lorem ipsum.

- +

Lorem ipsum.


spiral_next

Basis Function Combinator

[[[abs] ii <=] [[<>] [pop !-] ||] &&] [[!-] [[++]] [[--]] ifte dip] [[pop !-] [--] [++] ifte] ifte

Gentzen diagram.

-

Definition

+

Definition

if not basis.

-

Derivation

+

Derivation

if not basis.

-

Source

+

Source

if basis

-

Discussion

+

Discussion

Lorem ipsum.

- +

Lorem ipsum.


split_at

Basis Function Combinator

[drop] [take] clop

Gentzen diagram.

-

Definition

+

Definition

if not basis.

-

Derivation

+

Derivation

if not basis.

-

Source

+

Source

if basis

-

Discussion

+

Discussion

Lorem ipsum.

- +

Lorem ipsum.


split_list

Basis Function Combinator

[take reverse] [drop] clop

Gentzen diagram.

-

Definition

+

Definition

if not basis.

-

Derivation

+

Derivation

if not basis.

-

Source

+

Source

if basis

-

Discussion

+

Discussion

Lorem ipsum.

- +

Lorem ipsum.


sqr

Basis Function Combinator

dup *

Gentzen diagram.

-

Definition

+

Definition

if not basis.

-

Derivation

+

Derivation

if not basis.

-

Source

+

Source

if basis

-

Discussion

+

Discussion

Lorem ipsum.

- +

Lorem ipsum.


sqrt

Basis Function Combinator

Return the square root of the number a. Negative numbers return complex roots.

Gentzen diagram.

-

Definition

+

Definition

if not basis.

-

Derivation

+

Derivation

if not basis.

-

Source

+

Source

if basis

-

Discussion

+

Discussion

Lorem ipsum.

- +

Lorem ipsum.


stack

Basis Function Combinator

(... -- ... [...])

Gentzen diagram.

-

Definition

+

Definition

if not basis.

-

Derivation

+

Derivation

if not basis.

-

Source

+

Source

if basis

-

Discussion

+

Discussion

Lorem ipsum.

- +

Lorem ipsum.


stackd

Basis Function Combinator

[stack] dip

Gentzen diagram.

-

Definition

+

Definition

if not basis.

-

Derivation

+

Derivation

if not basis.

-

Source

+

Source

if basis

-

Discussion

+

Discussion

Lorem ipsum.

- +

Lorem ipsum.


step

@@ -2399,90 +2379,90 @@ a+b a-b ... 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

+

Definition

if not basis.

-

Derivation

+

Derivation

if not basis.

-

Source

+

Source

if basis

-

Discussion

+

Discussion

Lorem ipsum.

- +

Lorem ipsum.


step_zero

Basis Function Combinator

0 roll> step

Gentzen diagram.

-

Definition

+

Definition

if not basis.

-

Derivation

+

Derivation

if not basis.

-

Source

+

Source

if basis

-

Discussion

+

Discussion

Lorem ipsum.

- +

Lorem ipsum.


stuncons

Basis Function Combinator

(... a1 -- ... a1 a1 [...])

Gentzen diagram.

-

Definition

+

Definition

if not basis.

-

Derivation

+

Derivation

if not basis.

-

Source

+

Source

if basis

-

Discussion

+

Discussion

Lorem ipsum.

- +

Lorem ipsum.


stununcons

Basis Function Combinator

(... a2 a1 -- ... a2 a1 a1 a2 [...])

Gentzen diagram.

-

Definition

+

Definition

if not basis.

-

Derivation

+

Derivation

if not basis.

-

Source

+

Source

if basis

-

Discussion

+

Discussion

Lorem ipsum.

- +

Lorem ipsum.


sub

Basis Function Combinator

Same as a - b.

Gentzen diagram.

-

Definition

+

Definition

if not basis.

-

Derivation

+

Derivation

if not basis.

-

Source

+

Source

if basis

-

Discussion

+

Discussion

Lorem ipsum.

- +

Lorem ipsum.


succ

Basis Function Combinator

Increment TOS.

Gentzen diagram.

-

Definition

+

Definition

if not basis.

-

Derivation

+

Derivation

if not basis.

-

Source

+

Source

if basis

-

Discussion

+

Discussion

Lorem ipsum.

- +

Lorem ipsum.


sum

@@ -2490,105 +2470,105 @@ a+b a-b

Given a quoted sequence of numbers return the sum. :

sum == 0 swap [+] step

Gentzen diagram.

-

Definition

+

Definition

if not basis.

-

Derivation

+

Derivation

if not basis.

-

Source

+

Source

if basis

-

Discussion

+

Discussion

Lorem ipsum.

- +

Lorem ipsum.


swaack

Basis Function Combinator

([...1] -- [...0])

Gentzen diagram.

-

Definition

+

Definition

if not basis.

-

Derivation

+

Derivation

if not basis.

-

Source

+

Source

if basis

-

Discussion

+

Discussion

Lorem ipsum.

- +

Lorem ipsum.


swap

Basis Function Combinator

(a1 a2 -- a2 a1)

Gentzen diagram.

-

Definition

+

Definition

if not basis.

-

Derivation

+

Derivation

if not basis.

-

Source

+

Source

if basis

-

Discussion

+

Discussion

Lorem ipsum.

- +

Lorem ipsum.


swapd

Basis Function Combinator

[swap] dip

Gentzen diagram.

-

Definition

+

Definition

if not basis.

-

Derivation

+

Derivation

if not basis.

-

Source

+

Source

if basis

-

Discussion

+

Discussion

Lorem ipsum.

- +

Lorem ipsum.


swoncat

Basis Function Combinator

swap concat

Gentzen diagram.

-

Definition

+

Definition

if not basis.

-

Derivation

+

Derivation

if not basis.

-

Source

+

Source

if basis

-

Discussion

+

Discussion

Lorem ipsum.

- +

Lorem ipsum.


swons

Basis Function Combinator

([...1] a1 -- [a1 ...1])

Gentzen diagram.

-

Definition

+

Definition

if not basis.

-

Derivation

+

Derivation

if not basis.

-

Source

+

Source

if basis

-

Discussion

+

Discussion

Lorem ipsum.

- +

Lorem ipsum.


tailrec

Basis Function Combinator

[i] genrec

Gentzen diagram.

-

Definition

+

Definition

if not basis.

-

Derivation

+

Derivation

if not basis.

-

Source

+

Source

if basis

-

Discussion

+

Discussion

Lorem ipsum.

- +

Lorem ipsum.


take

@@ -2598,15 +2578,15 @@ a+b a-b ---------------------- [b a]

Gentzen diagram.

-

Definition

+

Definition

if not basis.

-

Derivation

+

Derivation

if not basis.

-

Source

+

Source

if basis

-

Discussion

+

Discussion

Lorem ipsum.

- +

Lorem ipsum.


ternary

@@ -2615,26 +2595,26 @@ a+b a-b
   ... z y x [P] unary
 -------------------------
          ... A
-

Definition

+

Definition

binary popd
-

Discussion

+

Discussion

Runs any other quoted function and returns its first result while consuming exactly three items from the stack.

- +

binary nullary unary


third

Basis Function Combinator

([a1 a2 a3 ...1] -- a3)

Gentzen diagram.

-

Definition

+

Definition

if not basis.

-

Derivation

+

Derivation

if not basis.

-

Source

+

Source

if basis

-

Discussion

+

Discussion

Lorem ipsum.

- +

Lorem ipsum.


times

@@ -2654,15 +2634,15 @@ a+b a-b ------------------------------------- w/ n > 1 ... . Q (n - 1) [Q] times

Gentzen diagram.

-

Definition

+

Definition

if not basis.

-

Derivation

+

Derivation

if not basis.

-

Source

+

Source

if basis

-

Discussion

+

Discussion

Lorem ipsum.

- +

Lorem ipsum.


truthy

@@ -2672,15 +2652,15 @@ a+b a-b

Basis Function Combinator

(a2 a1 -- a1 a2 a1)

Gentzen diagram.

-

Definition

+

Definition

if not basis.

-

Derivation

+

Derivation

if not basis.

-

Source

+

Source

if basis

-

Discussion

+

Discussion

Lorem ipsum.

- +

Lorem ipsum.


unary

@@ -2689,11 +2669,11 @@ a+b a-b
   ... x [P] unary
 ---------------------
        ... A
-

Definition

+

Definition

nullary popd
-

Discussion

+

Discussion

Runs any other quoted function and returns its first result while consuming exactly one item from the stack.

- +

binary nullary ternary


uncons

@@ -2702,131 +2682,131 @@ a+b a-b
   [A ...] uncons
 --------------------
       A [...]
-

Source

+

Source

func(uncons, Si, So) :- func(cons, So, Si).
-

Discussion

+

Discussion

This is the inverse of cons.

- +

cons


unique

Basis Function Combinator

Given a list remove duplicate items.

Gentzen diagram.

-

Definition

+

Definition

if not basis.

-

Derivation

+

Derivation

if not basis.

-

Source

+

Source

if basis

-

Discussion

+

Discussion

Lorem ipsum.

- +

Lorem ipsum.


unit

Basis Function Combinator

(a1 -- [a1 ])

Gentzen diagram.

-

Definition

+

Definition

if not basis.

-

Derivation

+

Derivation

if not basis.

-

Source

+

Source

if basis

-

Discussion

+

Discussion

Lorem ipsum.

- +

Lorem ipsum.


unquoted

Basis Function Combinator

[i] dip

Gentzen diagram.

-

Definition

+

Definition

if not basis.

-

Derivation

+

Derivation

if not basis.

-

Source

+

Source

if basis

-

Discussion

+

Discussion

Lorem ipsum.

- +

Lorem ipsum.


unswons

Basis Function Combinator

([a1 ...1] -- [...1] a1)

Gentzen diagram.

-

Definition

+

Definition

if not basis.

-

Derivation

+

Derivation

if not basis.

-

Source

+

Source

if basis

-

Discussion

+

Discussion

Lorem ipsum.

- +

Lorem ipsum.


void

Basis Function Combinator

True if the form on TOS is void otherwise False.

Gentzen diagram.

-

Definition

+

Definition

if not basis.

-

Derivation

+

Derivation

if not basis.

-

Source

+

Source

if basis

-

Discussion

+

Discussion

Lorem ipsum.

- +

Lorem ipsum.


warranty

Basis Function Combinator

Print warranty information.

Gentzen diagram.

-

Definition

+

Definition

if not basis.

-

Derivation

+

Derivation

if not basis.

-

Source

+

Source

if basis

-

Discussion

+

Discussion

Lorem ipsum.

- +

Lorem ipsum.


while

Basis Function Combinator

swap nulco dupdipd concat loop

Gentzen diagram.

-

Definition

+

Definition

if not basis.

-

Derivation

+

Derivation

if not basis.

-

Source

+

Source

if basis

-

Discussion

+

Discussion

Lorem ipsum.

- +

Lorem ipsum.


words

Basis Function Combinator

Print all the words in alphabetical order.

Gentzen diagram.

-

Definition

+

Definition

if not basis.

-

Derivation

+

Derivation

if not basis.

-

Source

+

Source

if basis

-

Discussion

+

Discussion

Lorem ipsum.

- +

Lorem ipsum.


x

@@ -2834,39 +2814,39 @@ a+b a-b
   [F] x
 -----------
    [F] F
-

Definition

+

Definition

dup i
-

Discussion

+

Discussion

The x combinator …


xor

Basis Function Combinator

Same as a ^ b.

Gentzen diagram.

-

Definition

+

Definition

if not basis.

-

Derivation

+

Derivation

if not basis.

-

Source

+

Source

if basis

-

Discussion

+

Discussion

Lorem ipsum.

- +

Lorem ipsum.


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

+

Definition

if not basis.

-

Derivation

+

Derivation

if not basis.

-

Source

+

Source

if basis

-

Discussion

+

Discussion

Lorem ipsum.

- +

Lorem ipsum.

diff --git a/docs/reference/mkref/Functor-Reference.md b/docs/reference/mkref/Functor-Reference.md index e7f9cf2..74e1a1b 100644 --- a/docs/reference/mkref/Functor-Reference.md +++ b/docs/reference/mkref/Functor-Reference.md @@ -1378,10 +1378,7 @@ them with a Boolean value. a b eq ------------- Boolean - -### Discussion - -Lorem ipsum. + (a = b) ### Crosslinks @@ -1580,200 +1577,179 @@ Replace a list with its fourth item. ## gcd -Basis Function Combinator - -true \[tuck mod dup 0 \>\] loop pop +Function -Gentzen diagram. +Take two integers from the stack and replace them with their Greatest +Common Denominator. ### Definition -if not basis. - -### Derivation - -if not basis. - -### Source - -if basis +> true \[[tuck] [mod] [dup] 0 [>]\] [loop] [pop] ### Discussion -Lorem ipsum. - -### Crosslinks +Euclid's Algorithm -Lorem ipsum. ------------------------------------------------------------------------ ## gcd2 -Basis Function Combinator +Function Compiled GCD function. -Gentzen diagram. +### Discussion -### Definition +See [gcd]. -if not basis. +### Crosslinks -### Derivation +[gcd] -if not basis. -### Source +------------------------------------------------------------------------ -if basis +## ge -### Discussion +Basis Function -Lorem ipsum. +Greater-than-or-equal-to comparison of two numbers. -### Crosslinks + a b ge + -------------- + Boolean + (a >= b) -Lorem ipsum. ------------------------------------------------------------------------- +### Crosslinks -## ge +[cmp] +[eq] +[gt] +[le] +[lt] +[ne] -Basis Function Combinator -Same as a \>= b. +------------------------------------------------------------------------ -Gentzen diagram. +## genrec -### Definition +Combinator -if not basis. +**Gen**eral **Rec**ursion Combinator. -### Derivation + [if] [then] [rec1] [rec2] genrec + --------------------------------------------------------------------- + [if] [then] [rec1 [[if] [then] [rec1] [rec2] genrec] rec2] ifte -if not basis. +### Definition -### Source +> \[\[[genrec]\] [ccccons]\] [nullary] [swons] [concat] [ifte] -if basis +(Note that this definition includes the `genrec` symbol itself, it is +self-referential. This is possible because the definition machinery does +not check that symbols in defs are in the dictionary. `genrec` is the +only self-referential definition.) ### Discussion -Lorem ipsum. - -### Crosslinks - -Lorem ipsum. +See the [Recursion Combinators notebook](https://joypy.osdn.io/notebooks/Recursion_Combinators.html). ------------------------------------------------------------------------- +From ["Recursion Theory and Joy"](https://www.kevinalbrecht.com/code/joy-mirror/j05cmp.html) +by Manfred von Thun: -## genrec +> "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." -Basis Function Combinator - -General Recursion 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. - [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\': : +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: : +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: : +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. : +Tail recursive functions are those where `R2` is the `i` combinator: 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 - -Lorem ipsum. - ### Crosslinks -Lorem ipsum. +[anamorphism] +[tailrec] +[x] + ------------------------------------------------------------------------ ## getitem -Basis Function Combinator - - getitem == drop first +Function Expects an integer and a quote on the stack and returns the item at the -nth position in the quote counting from 0. : +nth position in the quote counting from 0. - [a b c d] 0 getitem - ------------------------- - a +### Example -Gentzen diagram. + [a b c d] 2 getitem + ------------------------- + c ### Definition -if not basis. - -### Derivation - -if not basis. - -### Source - -if basis +> [drop] [first] ### Discussion -Lorem ipsum. +If the number isn't a valid index into the quote `getitem` will cause +some sort of problem (the exact nature of which is +implementation-dependant.) ### Crosslinks -Lorem ipsum. +[concat] +[first] +[first_two] +[flatten] +[fourth] +[remove] +[rest] +[reverse] +[rrest] +[second] +[shift] +[shunt] +[size] +[sort] +[split_at] +[split_list] +[swaack] +[third] +[zip] ------------------------------------------------------------------------