diff --git a/docs/reference/b.md b/docs/reference/b.md index 37647a1..49b7d0a 100644 --- a/docs/reference/b.md +++ b/docs/reference/b.md @@ -2,7 +2,7 @@ ## b -(Combinator) +Combinator Run two quoted programs @@ -12,19 +12,11 @@ Run two quoted programs ### Definition - [i] dip i - -### Derivation - - [P] [Q] b - [P] [Q] [i] dip i - [P] i [Q] i - P [Q] i - P Q +> \[[i]\] [dip] [i] ### Discussion -This combinator comes in handy. +This combinator may seem trivial but it comes in handy. ### Crosslinks diff --git a/docs/reference/binary.md b/docs/reference/binary.md index 182da5b..eab0aae 100644 --- a/docs/reference/binary.md +++ b/docs/reference/binary.md @@ -2,18 +2,18 @@ ## binary -(Combinator) +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 + ... a ### Definition - unary popd +> [unary] [popd] ### Discussion diff --git a/docs/reference/bool.md b/docs/reference/bool.md index 55a3288..e683717 100644 --- a/docs/reference/bool.md +++ b/docs/reference/bool.md @@ -2,32 +2,16 @@ ## bool -Basis Function Combinator +Basis Function -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 +Convert the item on the top of the stack to a Boolean value. ### Discussion -Lorem ipsum. +For integers 0 is `false` and any other number is `true`; for lists the +empty list is `false` and all other lists are `true`. ### Crosslinks -Lorem ipsum. +[not] + diff --git a/docs/reference/branch.md b/docs/reference/branch.md index 7fe9e83..a88eb4f 100644 --- a/docs/reference/branch.md +++ b/docs/reference/branch.md @@ -2,38 +2,33 @@ ## branch -Basis Function Combinator +Basis Combinator -Use a Boolean value to select one of two quoted programs to run. +Use a Boolean value to select and run one of two quoted programs. - branch == roll< choice i - False [F] [T] branch + false [F] [T] branch -------------------------- - F + F - True [F] [T] branch + true [F] [T] branch ------------------------- - T + T -Gentzen diagram. ### Definition -if not basis. - -### Derivation - -if not basis. - -### Source - -if basis +> [rolldown] [choice] [i] ### Discussion -Lorem ipsum. +This is one of the fundamental operations (although it can be defined in +terms of [choice] as above). The more common "if..then..else" construct +[ifte] adds a predicate function that is evaluated [nullary]. ### Crosslinks -Lorem ipsum. +[choice] +[ifte] +[select] + diff --git a/docs/reference/mkref/FuncRef.html b/docs/reference/mkref/FuncRef.html index 496cbb5..413045f 100644 --- a/docs/reference/mkref/FuncRef.html +++ b/docs/reference/mkref/FuncRef.html @@ -627,86 +627,71 @@
As an exercise in Functional Programming in Joy it would be fun to convert this into a catamorphism. See the Recursion Combinators notebook.
(Combinator)
+Combinator
Run two quoted programs
[P] [Q] b
---------------
P Q
[i] dip i
-[P] [Q] b
-[P] [Q] [i] dip i
-[P] i [Q] i
- P [Q] i
- P Q
++ +
This combinator comes in handy.
+This combinator may seem trivial but it comes in handy.
(Combinator)
+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
+ ... a
unary popd
++ +
Runs any other quoted function and returns its first result while consuming exactly two items from the stack.
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.
-if not basis.
-if not basis.
-if basis
+Basis Function
+Convert the item on the top of the stack to a Boolean value.
Lorem ipsum.
+For integers 0 is false and any other number is true; for lists the empty list is false and all other lists are true.
Lorem ipsum.
+Basis Function Combinator
-Use a Boolean value to select one of two quoted programs to run.
-branch == roll< choice i
-
-False [F] [T] branch
+Basis Combinator
+Use a Boolean value to select and run one of two quoted programs.
+ false [F] [T] branch
--------------------------
- F
+ F
-True [F] [T] branch
+ true [F] [T] branch
-------------------------
- T
-Gentzen diagram.
-Definition
-if not basis.
-Derivation
-if not basis.
-Source
-if basis
+ T
++ +
Lorem ipsum.
+This is one of the fundamental operations (although it can be defined in terms of choice as above). The more common “if..then..else” construct ifte adds a predicate function that is evaluated nullary.
Lorem ipsum.
+Basis Function Combinator
ccons ccons
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
Lorem ipsum.
@@ -719,7 +704,7 @@ True [F] [T] branch B A [...] ccons
---------------------
[B A ...]
-cons cons
Does cons twice.
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.
-if not basis.
-if not basis.
-if basis
Lorem ipsum.
@@ -760,11 +745,11 @@ A B true choiceGentzen diagram.
-if not basis.
-if not basis.
-if basis
Lorem ipsum.
@@ -775,11 +760,11 @@ A B true choiceBasis Function Combinator
fork popdd
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
Lorem ipsum.
@@ -790,11 +775,11 @@ A B true choiceBasis Function Combinator
cleave popdd
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
Lorem ipsum.
@@ -816,11 +801,11 @@ a b [G] [E] [L] cmp ------------------------- a < b LGentzen diagram.
-if not basis.
-if not basis.
-if basis
Lorem ipsum.
@@ -831,11 +816,11 @@ a b [G] [E] [L] cmpBasis Function Combinator
cons dip
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
Lorem ipsum.
@@ -846,11 +831,11 @@ a b [G] [E] [L] cmpBasis Function Combinator
codi reco
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
Lorem ipsum.
@@ -864,11 +849,11 @@ a b [G] [E] [L] cmp ---------------------------- [a b c d e f]Gentzen diagram.
-if not basis.
-if not basis.
-if basis
Lorem ipsum.
@@ -883,11 +868,11 @@ a b [G] [E] [L] cmp ----------------------------------------- [B0] [T0] [[B1] [T1] [D] ifte] ifteGentzen diagram.
-if not basis.
-if not basis.
-if basis
Lorem ipsum.
@@ -900,7 +885,7 @@ a b [G] [E] [L] cmp A [...] cons
------------------
[A ...]
-func(cons, [list(A), B|S], [list([B|A])|S]).
Cons is a venerable old function from Lisp. It doesn’t inspect the item but it will not cons onto a non-list. It’s inverse operation is called uncons.
Basis Function Combinator
dip infrst
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
Lorem ipsum.
@@ -929,11 +914,11 @@ a b [G] [E] [L] cmp ------------------- ... Q xGentzen diagram.
-if not basis.
-if not basis.
-if basis
Lorem ipsum.
@@ -947,11 +932,11 @@ a b [G] [E] [L] cmp --------------------- ... Q y xGentzen diagram.
-if not basis.
-if not basis.
-if basis
Lorem ipsum.
@@ -965,11 +950,11 @@ a b [G] [E] [L] cmp ----------------------- ... Q z y xGentzen diagram.
-if not basis.
-if not basis.
-if basis
Lorem ipsum.
@@ -980,11 +965,11 @@ a b [G] [E] [L] cmpBasis 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.
-if not basis.
-if not basis.
-if basis
Lorem ipsum.
@@ -999,11 +984,11 @@ a b [G] [E] [L] cmpdivmod(x, y) -> (quotient, remainder)
Return the tuple (x//y, x%y). Invariant: q * y + r == x.
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
Lorem ipsum.
@@ -1014,11 +999,11 @@ a b [G] [E] [L] cmpBasis Function Combinator
[0 >] [dup --] while
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
Lorem ipsum.
@@ -1033,11 +1018,11 @@ a b [G] [E] [L] cmp ---------------------- [c d]Gentzen diagram.
-if not basis.
-if not basis.
-if basis
Lorem ipsum.
@@ -1048,11 +1033,11 @@ a b [G] [E] [L] cmpBasis Function Combinator
(a1 -- a1 a1)
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
Lorem ipsum.
@@ -1063,11 +1048,11 @@ a b [G] [E] [L] cmpBasis Function Combinator
(a2 a1 -- a2 a2 a1)
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
Lorem ipsum.
@@ -1078,11 +1063,11 @@ a b [G] [E] [L] cmpBasis Function Combinator
(a3 a2 a1 -- a3 a3 a2 a1)
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
Lorem ipsum.
@@ -1098,11 +1083,11 @@ a b [G] [E] [L] cmp ... a a [F] dip ... a F aGentzen diagram.
-if not basis.
-if not basis.
-if basis
Lorem ipsum.
@@ -1113,11 +1098,11 @@ a b [G] [E] [L] cmpBasis Function Combinator
dup dipd
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
Lorem ipsum.
@@ -1128,11 +1113,11 @@ a b [G] [E] [L] cmpBasis Function Combinator
stack [clear] dip
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
Lorem ipsum.
@@ -1143,11 +1128,11 @@ a b [G] [E] [L] cmpBasis Function Combinator
Same as a == b.
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
Lorem ipsum.
@@ -1158,11 +1143,11 @@ a b [G] [E] [L] cmpBasis Function Combinator
([a1 ...1] -- a1)
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
Lorem ipsum.
@@ -1173,11 +1158,11 @@ a b [G] [E] [L] cmpBasis Function Combinator
([a1 a2 ...1] -- a1 a2)
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
Lorem ipsum.
@@ -1188,11 +1173,11 @@ a b [G] [E] [L] cmpBasis Function Combinator
<{} [concat] step
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
Lorem ipsum.
@@ -1204,11 +1189,11 @@ a b [G] [E] [L] cmpReturn the floor of x as an Integral.
This is the largest integer <= x.
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
Lorem ipsum.
@@ -1219,11 +1204,11 @@ a b [G] [E] [L] cmpBasis Function Combinator
Same as a // b.
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
Lorem ipsum.
@@ -1234,11 +1219,11 @@ a b [G] [E] [L] cmpBasis Function Combinator
[i] app2
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
Lorem ipsum.
@@ -1249,11 +1234,11 @@ a b [G] [E] [L] cmpBasis Function Combinator
([a1 a2 a3 a4 ...1] -- a4)
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
Lorem ipsum.
@@ -1264,11 +1249,11 @@ a b [G] [E] [L] cmpBasis Function Combinator
true [tuck mod dup 0 >] loop pop
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
Lorem ipsum.
@@ -1279,11 +1264,11 @@ a b [G] [E] [L] cmpBasis Function Combinator
Compiled GCD function.
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
Lorem ipsum.
@@ -1294,11 +1279,11 @@ a b [G] [E] [L] cmpBasis Function Combinator
Same as a >= b.
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
Lorem ipsum.
@@ -1325,11 +1310,11 @@ a b [G] [E] [L] cmp == [I] [T] [R [P] i] ifte == [I] [T] [R P] ifteGentzen diagram.
-if not basis.
-if not basis.
-if basis
Lorem ipsum.
@@ -1344,11 +1329,11 @@ a b [G] [E] [L] cmp ------------------------- aGentzen diagram.
-if not basis.
-if not basis.
-if basis
Lorem ipsum.
@@ -1359,11 +1344,11 @@ a b [G] [E] [L] cmpBasis Function Combinator
<{} [cons] times
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
Lorem ipsum.
@@ -1374,11 +1359,11 @@ a b [G] [E] [L] cmpBasis Function Combinator
[stack popd] dip
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
Lorem ipsum.
@@ -1389,11 +1374,11 @@ a b [G] [E] [L] cmpBasis Function Combinator
Same as a > b.
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
Lorem ipsum.
@@ -1404,11 +1389,11 @@ a b [G] [E] [L] cmpBasis Function Combinator
Accepts a quoted symbol on the top of the stack and prints its docs.
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
Lorem ipsum.
@@ -1419,11 +1404,11 @@ a b [G] [E] [L] cmpBasis Function Combinator
[sqr] ii + sqrt
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
Lorem ipsum.
@@ -1436,7 +1421,7 @@ a b [G] [E] [L] cmp [Q] i
-----------
Q
-combo(i, [list(P)|S], S, Ei, Eo) :- append(P, Ei, Eo).
This is probably the fundamental combinator. You wind up using it in all kinds of places (for example, the x combinator can be defined as dup i.)
Basis Function Combinator
The identity function.
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
Lorem ipsum.
@@ -1471,11 +1456,11 @@ a b [G] [E] [L] cmp ... [else] [then] [...] [if] infra first choice iHas the effect of grabbing a copy of the stack on which to run the if-part using infra.
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
Lorem ipsum.
@@ -1488,11 +1473,11 @@ a b [G] [E] [L] cmp ------------------ ... Q a QGentzen diagram.
-if not basis.
-if not basis.
-if basis
Lorem ipsum.
@@ -1505,7 +1490,7 @@ a b [G] [E] [L] cmp ... [a b c] [Q] infra
---------------------------
c b a Q [...] swaack
-swons swaack [i] dip swaack
This is one of the more useful combinators. It allows a quoted expression to serve as a stack for a program, effectively running it in a kind of “pocket universe”. If the list represents a datastructure then infra lets you work on its internal structure.
Basis Function Combinator
infra first
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
Lorem ipsum.
@@ -1534,11 +1519,11 @@ a b [G] [E] [L] cmp[sqr dup mul] inscribe
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
Lorem ipsum.
@@ -1549,11 +1534,11 @@ a b [G] [E] [L] cmpBasis Function Combinator
Same as a <= b.
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
Lorem ipsum.
@@ -1571,11 +1556,11 @@ a b [G] [E] [L] cmp ------------------------ ...Gentzen diagram.
-if not basis.
-if not basis.
-if basis
Lorem ipsum.
@@ -1586,11 +1571,11 @@ a b [G] [E] [L] cmpBasis Function Combinator
Same as a << b.
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
Lorem ipsum.
@@ -1601,11 +1586,11 @@ a b [G] [E] [L] cmpBasis Function Combinator
Same as a < b.
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
Lorem ipsum.
@@ -1616,11 +1601,11 @@ a b [G] [E] [L] cmpBasis Function Combinator
[codireco] ccons
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
Lorem ipsum.
@@ -1631,11 +1616,11 @@ a b [G] [E] [L] cmpBasis 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.
-if not basis.
-if not basis.
-if basis
Lorem ipsum.
@@ -1646,11 +1631,11 @@ a b [G] [E] [L] cmpBasis Function Combinator
Given a list find the maximum.
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
Lorem ipsum.
@@ -1661,11 +1646,11 @@ a b [G] [E] [L] cmpBasis Function Combinator
Given a list find the minimum.
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
Lorem ipsum.
@@ -1676,11 +1661,11 @@ a b [G] [E] [L] cmpBasis Function Combinator
Same as a % b.
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
Lorem ipsum.
@@ -1694,11 +1679,11 @@ a b [G] [E] [L] cmpBasis Function Combinator
Same as a * b.
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
Lorem ipsum.
@@ -1709,11 +1694,11 @@ a b [G] [E] [L] cmpBasis Function Combinator
Same as a != b.
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
Lorem ipsum.
@@ -1724,11 +1709,11 @@ a b [G] [E] [L] cmpBasis Function Combinator
Same as -a.
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
Lorem ipsum.
@@ -1739,11 +1724,11 @@ a b [G] [E] [L] cmpBasis Function Combinator
Same as not a.
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
Lorem ipsum.
@@ -1761,18 +1746,18 @@ a b [G] [E] [L] cmp N !- ---------- N >= 0 true -0 >=
Basis Function Combinator
[nullary] cons
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
Lorem ipsum.
@@ -1785,9 +1770,9 @@ a b [G] [E] [L] cmp ... [P] nullary
---------------------
... A
-[stack] dip infra first
-... [P] nullary
... [P] [stack] dip infra first
... stack [P] infra first
@@ -1803,11 +1788,11 @@ a b [G] [E] [L] cmp
Basis Function Combinator
swap at
Gentzen diagram.
-Definition
+Definition
if not basis.
-Derivation
+Derivation
if not basis.
-Source
+Source
if basis
Discussion
Lorem ipsum.
@@ -1818,11 +1803,11 @@ a b [G] [E] [L] cmp
Basis Function Combinator
Same as a | b.
Gentzen diagram.
-Definition
+Definition
if not basis.
-Derivation
+Derivation
if not basis.
-Source
+Source
if basis
Discussion
Lorem ipsum.
@@ -1833,11 +1818,11 @@ a b [G] [E] [L] cmp
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
Lorem ipsum.
@@ -1848,11 +1833,11 @@ a b [G] [E] [L] cmp
Basis Function Combinator
[i] map
Gentzen diagram.
-Definition
+Definition
if not basis.
-Derivation
+Derivation
if not basis.
-Source
+Source
if basis
Discussion
Lorem ipsum.
@@ -1869,11 +1854,11 @@ a b [G] [E] [L] cmp
-------------
a+b a-b
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
Lorem ipsum.
@@ -1884,11 +1869,11 @@ a+b a-bBasis Function Combinator
(a1 --)
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
Lorem ipsum.
@@ -1899,11 +1884,11 @@ a+b a-bBasis Function Combinator
(a2 a1 -- a1)
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
Lorem ipsum.
@@ -1914,11 +1899,11 @@ a+b a-bBasis Function Combinator
(a3 a2 a1 -- a2 a1)
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
Lorem ipsum.
@@ -1929,11 +1914,11 @@ a+b a-bBasis Function Combinator
(a2 a1 --)
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
Lorem ipsum.
@@ -1944,11 +1929,11 @@ a+b a-bBasis Function Combinator
(a3 a2 a1 -- a1)
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
Lorem ipsum.
@@ -1959,11 +1944,11 @@ a+b a-bBasis Function Combinator
(a4 a3 a2 a1 -- a2 a1)
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
Lorem ipsum.
@@ -1974,11 +1959,11 @@ a+b a-bBasis Function Combinator
pop popop
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
Lorem ipsum.
@@ -1989,11 +1974,11 @@ a+b a-bBasis Function Combinator
Same as a ** b.
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
Lorem ipsum.
@@ -2004,11 +1989,11 @@ a+b a-bBasis Function Combinator
Decrement TOS.
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
Lorem ipsum.
@@ -2031,11 +2016,11 @@ a+b a-b ------------------------------------------ n > 0 n (n-1) [Base] [Recur] primrec RecurGentzen diagram.
-if not basis.
-if not basis.
-if basis
Lorem ipsum.
@@ -2046,11 +2031,11 @@ a+b a-bBasis Function Combinator
1 swap [*] step
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
Lorem ipsum.
@@ -2061,11 +2046,11 @@ a+b a-bBasis Function Combinator
[unit] dip
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
Lorem ipsum.
@@ -2076,11 +2061,11 @@ a+b a-bBasis Function Combinator
[0 <=] [1 - dup] anamorphism
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
Lorem ipsum.
@@ -2091,11 +2076,11 @@ a+b a-bBasis Function Combinator
unit [down_to_zero] infra
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
Lorem ipsum.
@@ -2106,11 +2091,11 @@ a+b a-bBasis Function Combinator
rest cons
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
Lorem ipsum.
@@ -2130,11 +2115,11 @@ a+b a-b ------------------------ [2 3 1]Gentzen diagram.
-if not basis.
-if not basis.
-if basis
Lorem ipsum.
@@ -2145,11 +2130,11 @@ a+b a-bBasis Function Combinator
([a1 ...0] -- [...0])
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
Lorem ipsum.
@@ -2161,11 +2146,11 @@ a+b a-bReverse the list on the top of the stack. :
reverse == [] swap shunt
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
Lorem ipsum.
@@ -2176,11 +2161,11 @@ a+b a-bBasis Function Combinator
(a1 a2 a3 -- a2 a3 a1)
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
Lorem ipsum.
@@ -2191,11 +2176,11 @@ a+b a-bBasis Function Combinator
(a1 a2 a3 -- a3 a1 a2)
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
Lorem ipsum.
@@ -2213,11 +2198,11 @@ a+b a-bRound 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.
-if not basis.
-if not basis.
-if basis
Lorem ipsum.
@@ -2228,11 +2213,11 @@ a+b a-bBasis Function Combinator
([a1 a2 ...1] -- [...1])
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
Lorem ipsum.
@@ -2243,11 +2228,11 @@ a+b a-bBasis Function Combinator
Same as a >> b.
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
Lorem ipsum.
@@ -2258,11 +2243,11 @@ a+b a-bBasis Function Combinator
<{} infra
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
Lorem ipsum.
@@ -2273,11 +2258,11 @@ a+b a-bBasis Function Combinator
([a1 a2 ...1] -- a2)
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
Lorem ipsum.
@@ -2297,11 +2282,11 @@ a+b a-b BThe 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.
-if not basis.
-if not basis.
-if basis
Lorem ipsum.
@@ -2312,11 +2297,11 @@ a+b a-bBasis Function Combinator
Print redistribution information.
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
Lorem ipsum.
@@ -2327,11 +2312,11 @@ a+b a-bBasis Function Combinator
uncons [swons] dip
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
Lorem ipsum.
@@ -2347,11 +2332,11 @@ a+b a-b --------------------------- [f e d a b c]Gentzen diagram.
-if not basis.
-if not basis.
-if basis
Lorem ipsum.
@@ -2362,11 +2347,11 @@ a+b a-bBasis Function Combinator
[pop ++] step_zero
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
Lorem ipsum.
@@ -2377,11 +2362,11 @@ a+b a-bBasis Function Combinator
Given a list return it sorted.
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
Lorem ipsum.
@@ -2392,11 +2377,11 @@ a+b a-bBasis Function Combinator
[[[abs] ii <=] [[<>] [pop !-] ||] &&] [[!-] [[++]] [[--]] ifte dip] [[pop !-] [--] [++] ifte] ifte
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
Lorem ipsum.
@@ -2407,11 +2392,11 @@ a+b a-bBasis Function Combinator
[drop] [take] clop
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
Lorem ipsum.
@@ -2422,11 +2407,11 @@ a+b a-bBasis Function Combinator
[take reverse] [drop] clop
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
Lorem ipsum.
@@ -2437,11 +2422,11 @@ a+b a-bBasis Function Combinator
dup *
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
Lorem ipsum.
@@ -2452,11 +2437,11 @@ a+b a-bBasis Function Combinator
Return the square root of the number a. Negative numbers return complex roots.
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
Lorem ipsum.
@@ -2467,11 +2452,11 @@ a+b a-bBasis Function Combinator
(... -- ... [...])
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
Lorem ipsum.
@@ -2482,11 +2467,11 @@ a+b a-bBasis Function Combinator
[stack] dip
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
Lorem ipsum.
@@ -2511,11 +2496,11 @@ a+b a-b ... a . Q [b c] [Q] stepThe step combinator executes the quotation on each member of the list on top of the stack.
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
Lorem ipsum.
@@ -2526,11 +2511,11 @@ a+b a-bBasis Function Combinator
0 roll> step
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
Lorem ipsum.
@@ -2541,11 +2526,11 @@ a+b a-bBasis Function Combinator
(... a1 -- ... a1 a1 [...])
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
Lorem ipsum.
@@ -2556,11 +2541,11 @@ a+b a-bBasis Function Combinator
(... a2 a1 -- ... a2 a1 a1 a2 [...])
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
Lorem ipsum.
@@ -2571,11 +2556,11 @@ a+b a-bBasis Function Combinator
Same as a - b.
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
Lorem ipsum.
@@ -2586,11 +2571,11 @@ a+b a-bBasis Function Combinator
Increment TOS.
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
Lorem ipsum.
@@ -2602,11 +2587,11 @@ a+b a-bGiven a quoted sequence of numbers return the sum. :
sum == 0 swap [+] step
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
Lorem ipsum.
@@ -2617,11 +2602,11 @@ a+b a-bBasis Function Combinator
([...1] -- [...0])
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
Lorem ipsum.
@@ -2632,11 +2617,11 @@ a+b a-bBasis Function Combinator
(a1 a2 -- a2 a1)
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
Lorem ipsum.
@@ -2647,11 +2632,11 @@ a+b a-bBasis Function Combinator
[swap] dip
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
Lorem ipsum.
@@ -2662,11 +2647,11 @@ a+b a-bBasis Function Combinator
swap concat
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
Lorem ipsum.
@@ -2677,11 +2662,11 @@ a+b a-bBasis Function Combinator
([...1] a1 -- [a1 ...1])
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
Lorem ipsum.
@@ -2692,11 +2677,11 @@ a+b a-bBasis Function Combinator
[i] genrec
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
Lorem ipsum.
@@ -2710,11 +2695,11 @@ a+b a-b ---------------------- [b a]Gentzen diagram.
-if not basis.
-if not basis.
-if basis
Lorem ipsum.
@@ -2727,7 +2712,7 @@ a+b a-b ... z y x [P] unary
-------------------------
... A
-binary popd
Runs any other quoted function and returns its first result while consuming exactly three items from the stack.
@@ -2738,11 +2723,11 @@ a+b a-bBasis Function Combinator
([a1 a2 a3 ...1] -- a3)
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
Lorem ipsum.
@@ -2766,11 +2751,11 @@ a+b a-b ------------------------------------- w/ n > 1 ... . Q (n - 1) [Q] timesGentzen diagram.
-if not basis.
-if not basis.
-if basis
Lorem ipsum.
@@ -2784,11 +2769,11 @@ a+b a-bBasis Function Combinator
(a2 a1 -- a1 a2 a1)
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
Lorem ipsum.
@@ -2801,7 +2786,7 @@ a+b a-b ... x [P] unary
---------------------
... A
-nullary popd
Runs any other quoted function and returns its first result while consuming exactly one item from the stack.
@@ -2814,7 +2799,7 @@ a+b a-b [A ...] uncons
--------------------
A [...]
-func(uncons, Si, So) :- func(cons, So, Si).
This is the inverse of cons.
Basis Function Combinator
Given a list remove duplicate items.
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
Lorem ipsum.
@@ -2840,11 +2825,11 @@ a+b a-bBasis Function Combinator
(a1 -- [a1 ])
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
Lorem ipsum.
@@ -2855,11 +2840,11 @@ a+b a-bBasis Function Combinator
[i] dip
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
Lorem ipsum.
@@ -2870,11 +2855,11 @@ a+b a-bBasis Function Combinator
([a1 ...1] -- [...1] a1)
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
Lorem ipsum.
@@ -2885,11 +2870,11 @@ a+b a-bBasis Function Combinator
True if the form on TOS is void otherwise False.
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
Lorem ipsum.
@@ -2900,11 +2885,11 @@ a+b a-bBasis Function Combinator
Print warranty information.
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
Lorem ipsum.
@@ -2915,11 +2900,11 @@ a+b a-bBasis Function Combinator
swap nulco dupdipd concat loop
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
Lorem ipsum.
@@ -2930,11 +2915,11 @@ a+b a-bBasis Function Combinator
Print all the words in alphabetical order.
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
Lorem ipsum.
@@ -2946,7 +2931,7 @@ a+b a-b [F] x
-----------
[F] F
-dup i
The x combinator …
Basis Function Combinator
Same as a ^ b.
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
Lorem ipsum.
@@ -2970,11 +2955,11 @@ a+b a-bBasis 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.
-if not basis.
-if not basis.
-if basis
Lorem ipsum.
diff --git a/docs/reference/mkref/Functor-Reference.md b/docs/reference/mkref/Functor-Reference.md index a8d9fb1..f1d79ba 100644 --- a/docs/reference/mkref/Functor-Reference.md +++ b/docs/reference/mkref/Functor-Reference.md @@ -563,7 +563,7 @@ See the [Recursion Combinators notebook](https://joypy.osdn.io/notebooks/Recursi ## b -(Combinator) +Combinator Run two quoted programs @@ -573,19 +573,11 @@ Run two quoted programs ### Definition - [i] dip i - -### Derivation - - [P] [Q] b - [P] [Q] [i] dip i - [P] i [Q] i - P [Q] i - P Q +> \[[i]\] [dip] [i] ### Discussion -This combinator comes in handy. +This combinator may seem trivial but it comes in handy. ### Crosslinks @@ -597,18 +589,18 @@ This combinator comes in handy. ## binary -(Combinator) +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 + ... a ### Definition - unary popd +> [unary] [popd] ### Discussion @@ -626,75 +618,54 @@ consuming exactly two items from the stack. ## bool -Basis Function Combinator +Basis Function -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 +Convert the item on the top of the stack to a Boolean value. ### Discussion -Lorem ipsum. +For integers 0 is `false` and any other number is `true`; for lists the +empty list is `false` and all other lists are `true`. ### Crosslinks -Lorem ipsum. +[not] + ------------------------------------------------------------------------ ## branch -Basis Function Combinator +Basis Combinator -Use a Boolean value to select one of two quoted programs to run. +Use a Boolean value to select and run one of two quoted programs. - branch == roll< choice i - False [F] [T] branch + false [F] [T] branch -------------------------- - F + F - True [F] [T] branch + true [F] [T] branch ------------------------- - T + T -Gentzen diagram. ### Definition -if not basis. - -### Derivation - -if not basis. - -### Source - -if basis +> [rolldown] [choice] [i] ### Discussion -Lorem ipsum. +This is one of the fundamental operations (although it can be defined in +terms of [choice] as above). The more common "if..then..else" construct +[ifte] adds a predicate function that is evaluated [nullary]. ### Crosslinks -Lorem ipsum. +[choice] +[ifte] +[select] + ------------------------------------------------------------------------