diff --git a/docs/reference/ccccons.md b/docs/reference/ccccons.md index 1196090..ae3f3b2 100644 --- a/docs/reference/ccccons.md +++ b/docs/reference/ccccons.md @@ -2,28 +2,19 @@ ## ccccons -Basis Function Combinator +Function -ccons ccons + a b c d [...] ccccons + --------------------------- + [a b c d ...] -Gentzen diagram. +Do [cons] four times. ### Definition -if not basis. - -### Derivation - -if not basis. - -### Source - -if basis - -### Discussion - -Lorem ipsum. +> [ccons] [ccons] ### Crosslinks -Lorem ipsum. +[ccons] [cons] [times] + diff --git a/docs/reference/ccons.md b/docs/reference/ccons.md index 0afb708..5a179b0 100644 --- a/docs/reference/ccons.md +++ b/docs/reference/ccons.md @@ -2,23 +2,20 @@ ## ccons -(Function) +Function -Given two items and a list, append the items to the list to make a new list. - - B A [...] ccons + a b [...] ccons --------------------- - [B A ...] + [a b ...] + +Do [cons] two times. ### Definition - cons cons - -### Discussion - -Does `cons` twice. +> [cons] [cons] ### Crosslinks -[cons](#cons) +[cons] +[ccons] diff --git a/docs/reference/choice.md b/docs/reference/choice.md index 6110001..5122a8f 100644 --- a/docs/reference/choice.md +++ b/docs/reference/choice.md @@ -2,41 +2,29 @@ ## choice -Basis Function Combinator +Basis Function -Use a Boolean value to select one of two items. : +Use a Boolean value to select one of two items. - A B false choice + a b false choice ---------------------- - A + a - - A B true choice + a b true choice --------------------- - B - -Currently Python semantics are used to evaluate the \"truthiness\" of -the Boolean value (so empty string, zero, etc. are counted as false, -etc.) - -Gentzen diagram. + b ### Definition -if not basis. - -### Derivation - -if not basis. - -### Source - -if basis +> \[[pop]\] \[[popd]\] [branch] ### Discussion -Lorem ipsum. +It's a matter of taste whether you implement this in terms of [branch] or +the other way around. ### Crosslinks -Lorem ipsum. +[branch] +[select] + diff --git a/docs/reference/clear.md b/docs/reference/clear.md index e2a0720..a92e930 100644 --- a/docs/reference/clear.md +++ b/docs/reference/clear.md @@ -2,33 +2,16 @@ ## clear -Basis Function Combinator +Basis Function Clear everything from the stack. -: clear == stack [pop stack] loop - - ... clear - --------------- - -Gentzen diagram. - ### Definition -if not basis. - -### Derivation - -if not basis. - -### Source - -if basis - -### Discussion - -Lorem ipsum. +> [stack] [bool] \[[pop] [stack] [bool]\] [loop] ### Crosslinks -Lorem ipsum. +[stack] +[swaack] + diff --git a/docs/reference/cleave.md b/docs/reference/cleave.md index 91169dd..195f67f 100644 --- a/docs/reference/cleave.md +++ b/docs/reference/cleave.md @@ -2,28 +2,32 @@ ## cleave -Basis Function Combinator +Combinator -fork popdd +Run two programs in parallel, consuming one additional item, and put their +results on the stack. -Gentzen diagram. - -### Definition - -if not basis. + ... x [A] [B] cleave + ------------------------ + ... a b ### Derivation -if not basis. +> [fork] [popdd] -### Source +### Example -if basis + 1 2 3 [+] [-] cleave + -------------------------- + 1 2 5 -1 ### Discussion -Lorem ipsum. +One of a handful of useful parallel combinators. ### Crosslinks -Lorem ipsum. +[clop] +[fork] +[map] + diff --git a/docs/reference/clop.md b/docs/reference/clop.md index 6963bbb..6983b6f 100644 --- a/docs/reference/clop.md +++ b/docs/reference/clop.md @@ -2,28 +2,29 @@ ## clop -Basis Function Combinator +Combinator -cleave popdd +Run two programs in parallel, consuming two additional items, and put their results on the stack. -Gentzen diagram. + ... x y [A] [B] clop + -------------------------- + ... a b ### Definition -if not basis. - -### Derivation - -if not basis. - -### Source - -if basis +> [cleave] [popdd] ### Discussion -Lorem ipsum. +Like [cleave] but consumes an additional item from the stack. + + 1 2 3 4 [+] [-] clop + -------------------------- + 1 2 7 -1 ### Crosslinks -Lorem ipsum. +[cleave] +[fork] +[map] + diff --git a/docs/reference/cmp.md b/docs/reference/cmp.md index 650ecbe..b992eb1 100644 --- a/docs/reference/cmp.md +++ b/docs/reference/cmp.md @@ -2,41 +2,37 @@ ## cmp -Basis Function Combinator +Combinator -cmp takes two values and three quoted programs on the stack and runs one -of the three depending on the results of comparing the two values: : +Take two values and three quoted programs on the stack and run one +of the three depending on the results of comparing the two values. - a b [G] [E] [L] cmp + a b [G] [E] [L] cmp ------------------------- a > b - G + G - a b [G] [E] [L] cmp + a b [G] [E] [L] cmp ------------------------- a = b - E + E - a b [G] [E] [L] cmp + a b [G] [E] [L] cmp ------------------------- a < b - L - -Gentzen diagram. - -### Definition - -if not basis. - -### Derivation - -if not basis. - -### Source - -if basis - + L ### Discussion -Lorem ipsum. +This is useful sometimes, and you can [dup] or [dupd] with two quoted +programs to handle the cases when you just want to deal with [<=] or [>=] +and not all three possibilities, e.g.: + + [G] [LE] dup cmp + + [GE] [L] dupd cmp + +Or even: + + [GL] [E] over cmp ### Crosslinks -Lorem ipsum. +TODO: link to tree notebooks where this was used. + diff --git a/docs/reference/codi.md b/docs/reference/codi.md index b1f0c13..ed57f8e 100644 --- a/docs/reference/codi.md +++ b/docs/reference/codi.md @@ -2,28 +2,26 @@ ## codi -Basis Function Combinator +Combinator -cons dip - -Gentzen diagram. +Take a quoted program from the stack, [cons] the next item onto it, then +[dip] the whole thing under what was the third item on the stack. + + a b [F] . codi + -------------------- + b . F a ### Definition -if not basis. - -### Derivation - -if not basis. - -### Source - -if basis +> [cons] [dip] ### Discussion -Lorem ipsum. +This is one of those weirdly specific functions that turns out to be +useful in a few places. ### Crosslinks -Lorem ipsum. +[appN] +[codireco] + diff --git a/docs/reference/mkref/FuncRef.html b/docs/reference/mkref/FuncRef.html index 413045f..16d0a74 100644 --- a/docs/reference/mkref/FuncRef.html +++ b/docs/reference/mkref/FuncRef.html @@ -684,160 +684,147 @@
Basis Function Combinator
-ccons ccons
-Gentzen diagram.
+Function
+ a b c d [...] ccccons
+---------------------------
+ [a b c d ...]
+Do cons four times.
if not basis.
-if not basis.
-if basis
-Lorem ipsum.
++ +
Lorem ipsum.
+(Function)
-Given two items and a list, append the items to the list to make a new list.
- B A [...] ccons
+Function
+ a b [...] ccons
---------------------
- [B A ...]
+ [a b ...]
+Do cons two times.
cons cons
-Does cons twice.
+ +
Basis Function Combinator
-Use a Boolean value to select one of two items. :
-A B false choice
+Basis Function
+Use a Boolean value to select one of two items.
+ a b false choice
----------------------
-A
+ a
-
-A B true choice
+ a b true choice
---------------------
- B
-Currently Python semantics are used to evaluate the "truthiness" of the Boolean value (so empty string, zero, etc. are counted as false, etc.)
-Gentzen diagram.
+ b
if not basis.
-if not basis.
-if basis
-Lorem ipsum.
++ ++
It’s a matter of taste whether you implement this in terms of branch or the other way around.
Lorem ipsum.
+Basis Function Combinator
-clear == stack [pop stack] loop
- ... clear
----------------
-Gentzen diagram.
+Basis Function
+Clear everything from the stack.
if not basis.
-if not basis.
-if basis
-Lorem ipsum.
++ +
Lorem ipsum.
+Basis Function Combinator
-fork popdd
-Gentzen diagram.
-if not basis.
-if not basis.
-if basis
-Lorem ipsum.
+Combinator
+Run two programs in parallel, consuming one additional item, and put their results on the stack.
+ ... x [A] [B] cleave
+------------------------
+ ... a b
++ ++
1 2 3 [+] [-] cleave
+--------------------------
+ 1 2 5 -1
+One of a handful of useful parallel combinators.
Lorem ipsum.
+Basis Function Combinator
-cleave popdd
-Gentzen diagram.
-if not basis.
-if not basis.
-if basis
-Lorem ipsum.
+Combinator
+Run two programs in parallel, consuming two additional items, and put their results on the stack.
+ ... x y [A] [B] clop
+--------------------------
+ ... a b
++ ++
Like cleave but consumes an additional item from the stack.
+ 1 2 3 4 [+] [-] clop
+--------------------------
+ 1 2 7 -1
Lorem ipsum.
+Basis Function Combinator
-cmp takes two values and three quoted programs on the stack and runs one of the three depending on the results of comparing the two values: :
-a b [G] [E] [L] cmp
+Combinator
+Take two values and three quoted programs on the stack and run one of the three depending on the results of comparing the two values.
+ a b [G] [E] [L] cmp
------------------------- a > b
- G
+ G
-a b [G] [E] [L] cmp
+ a b [G] [E] [L] cmp
------------------------- a = b
- E
+ E
-a b [G] [E] [L] cmp
+ a b [G] [E] [L] cmp
------------------------- a < b
- L
-Gentzen diagram.
-Definition
-if not basis.
-Derivation
-if not basis.
-Source
-if basis
-Discussion
-Lorem ipsum.
+ L
+This is useful sometimes, and you can dup or dupd with two quoted programs to handle the cases when you just want to deal with <= or >= and not all three possibilities, e.g.:
+[G] [LE] dup cmp
+
+[GE] [L] dupd cmp
+Or even:
+[GL] [E] over cmp
Lorem ipsum.
+TODO: link to tree notebooks where this was used.
Basis Function Combinator
-cons dip
-Gentzen diagram.
-if not basis.
-if not basis.
-if basis
-Lorem ipsum.
+Combinator
+Take a quoted program from the stack, cons the next item onto it, then dip the whole thing under what was the third item on the stack.
+ a b [F] . codi
+--------------------
+ b . F a
++ ++
This is one of those weirdly specific functions that turns out to be useful in a few places.
Lorem ipsum.
+Basis Function Combinator
codi reco
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
-Lorem ipsum.
Lorem ipsum.
@@ -849,13 +836,13 @@ a b [G] [E] [L] cmp ---------------------------- [a b c d e f]Gentzen diagram.
-if not basis.
-if not basis.
-if basis
-Lorem ipsum.
Lorem ipsum.
@@ -868,13 +855,13 @@ a b [G] [E] [L] cmp ----------------------------------------- [B0] [T0] [[B1] [T1] [D] ifte] ifteGentzen diagram.
-if not basis.
-if not basis.
-if basis
-Lorem ipsum.
Lorem ipsum.
@@ -885,9 +872,9 @@ 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.
Lorem ipsum.
@@ -914,13 +901,13 @@ a b [G] [E] [L] cmp ------------------- ... Q xGentzen diagram.
-if not basis.
-if not basis.
-if basis
-Lorem ipsum.
Lorem ipsum.
@@ -932,13 +919,13 @@ a b [G] [E] [L] cmp --------------------- ... Q y xGentzen diagram.
-if not basis.
-if not basis.
-if basis
-Lorem ipsum.
Lorem ipsum.
@@ -950,13 +937,13 @@ a b [G] [E] [L] cmp ----------------------- ... Q z y xGentzen diagram.
-if not basis.
-if not basis.
-if basis
-Lorem ipsum.
Lorem ipsum.
@@ -965,13 +952,13 @@ 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.
Lorem ipsum.
@@ -984,13 +971,13 @@ 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.
Lorem ipsum.
@@ -999,13 +986,13 @@ a b [G] [E] [L] cmpBasis Function Combinator
[0 >] [dup --] while
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
-Lorem ipsum.
Lorem ipsum.
@@ -1018,13 +1005,13 @@ a b [G] [E] [L] cmp ---------------------- [c d]Gentzen diagram.
-if not basis.
-if not basis.
-if basis
-Lorem ipsum.
Lorem ipsum.
@@ -1033,13 +1020,13 @@ a b [G] [E] [L] cmpBasis Function Combinator
(a1 -- a1 a1)
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
-Lorem ipsum.
Lorem ipsum.
@@ -1048,13 +1035,13 @@ 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.
Lorem ipsum.
@@ -1063,13 +1050,13 @@ 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.
Lorem ipsum.
@@ -1083,13 +1070,13 @@ a b [G] [E] [L] cmp ... a a [F] dip ... a F aGentzen diagram.
-if not basis.
-if not basis.
-if basis
-Lorem ipsum.
Lorem ipsum.
@@ -1098,13 +1085,13 @@ a b [G] [E] [L] cmpBasis Function Combinator
dup dipd
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
-Lorem ipsum.
Lorem ipsum.
@@ -1113,13 +1100,13 @@ a b [G] [E] [L] cmpBasis Function Combinator
stack [clear] dip
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
-Lorem ipsum.
Lorem ipsum.
@@ -1128,13 +1115,13 @@ a b [G] [E] [L] cmpBasis Function Combinator
Same as a == b.
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
-Lorem ipsum.
Lorem ipsum.
@@ -1143,13 +1130,13 @@ a b [G] [E] [L] cmpBasis Function Combinator
([a1 ...1] -- a1)
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
-Lorem ipsum.
Lorem ipsum.
@@ -1158,13 +1145,13 @@ 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.
Lorem ipsum.
@@ -1173,13 +1160,13 @@ a b [G] [E] [L] cmpBasis Function Combinator
<{} [concat] step
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
-Lorem ipsum.
Lorem ipsum.
@@ -1189,13 +1176,13 @@ 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.
Lorem ipsum.
@@ -1204,13 +1191,13 @@ a b [G] [E] [L] cmpBasis Function Combinator
Same as a // b.
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
-Lorem ipsum.
Lorem ipsum.
@@ -1219,13 +1206,13 @@ a b [G] [E] [L] cmpBasis Function Combinator
[i] app2
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
-Lorem ipsum.
Lorem ipsum.
@@ -1234,13 +1221,13 @@ 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.
Lorem ipsum.
@@ -1249,13 +1236,13 @@ 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.
Lorem ipsum.
@@ -1264,13 +1251,13 @@ a b [G] [E] [L] cmpBasis Function Combinator
Compiled GCD function.
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
-Lorem ipsum.
Lorem ipsum.
@@ -1279,13 +1266,13 @@ a b [G] [E] [L] cmpBasis Function Combinator
Same as a >= b.
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
-Lorem ipsum.
Lorem ipsum.
@@ -1310,13 +1297,13 @@ 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.
Lorem ipsum.
@@ -1329,13 +1316,13 @@ a b [G] [E] [L] cmp ------------------------- aGentzen diagram.
-if not basis.
-if not basis.
-if basis
-Lorem ipsum.
Lorem ipsum.
@@ -1344,13 +1331,13 @@ a b [G] [E] [L] cmpBasis Function Combinator
<{} [cons] times
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
-Lorem ipsum.
Lorem ipsum.
@@ -1359,13 +1346,13 @@ a b [G] [E] [L] cmpBasis Function Combinator
[stack popd] dip
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
-Lorem ipsum.
Lorem ipsum.
@@ -1374,13 +1361,13 @@ a b [G] [E] [L] cmpBasis Function Combinator
Same as a > b.
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
-Lorem ipsum.
Lorem ipsum.
@@ -1389,13 +1376,13 @@ 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.
Lorem ipsum.
@@ -1404,13 +1391,13 @@ a b [G] [E] [L] cmpBasis Function Combinator
[sqr] ii + sqrt
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
-Lorem ipsum.
Lorem ipsum.
@@ -1421,22 +1408,22 @@ 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.
Lorem ipsum.
@@ -1456,13 +1443,13 @@ 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.
Lorem ipsum.
@@ -1473,13 +1460,13 @@ a b [G] [E] [L] cmp ------------------ ... Q a QGentzen diagram.
-if not basis.
-if not basis.
-if basis
-Lorem ipsum.
Lorem ipsum.
@@ -1490,9 +1477,9 @@ 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.
Lorem ipsum.
@@ -1519,13 +1506,13 @@ a b [G] [E] [L] cmp[sqr dup mul] inscribe
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
-Lorem ipsum.
Lorem ipsum.
@@ -1534,13 +1521,13 @@ a b [G] [E] [L] cmpBasis Function Combinator
Same as a <= b.
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
-Lorem ipsum.
Lorem ipsum.
@@ -1556,13 +1543,13 @@ a b [G] [E] [L] cmp ------------------------ ...Gentzen diagram.
-if not basis.
-if not basis.
-if basis
-Lorem ipsum.
Lorem ipsum.
@@ -1571,13 +1558,13 @@ a b [G] [E] [L] cmpBasis Function Combinator
Same as a << b.
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
-Lorem ipsum.
Lorem ipsum.
@@ -1586,13 +1573,13 @@ a b [G] [E] [L] cmpBasis Function Combinator
Same as a < b.
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
-Lorem ipsum.
Lorem ipsum.
@@ -1601,13 +1588,13 @@ a b [G] [E] [L] cmpBasis Function Combinator
[codireco] ccons
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
-Lorem ipsum.
Lorem ipsum.
@@ -1616,13 +1603,13 @@ 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.
Lorem ipsum.
@@ -1631,13 +1618,13 @@ 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.
Lorem ipsum.
@@ -1646,13 +1633,13 @@ 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.
Lorem ipsum.
@@ -1661,13 +1648,13 @@ a b [G] [E] [L] cmpBasis Function Combinator
Same as a % b.
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
-Lorem ipsum.
Lorem ipsum.
@@ -1679,13 +1666,13 @@ a b [G] [E] [L] cmpBasis Function Combinator
Same as a * b.
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
-Lorem ipsum.
Lorem ipsum.
@@ -1694,13 +1681,13 @@ a b [G] [E] [L] cmpBasis Function Combinator
Same as a != b.
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
-Lorem ipsum.
Lorem ipsum.
@@ -1709,13 +1696,13 @@ a b [G] [E] [L] cmpBasis Function Combinator
Same as -a.
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
-Lorem ipsum.
Lorem ipsum.
@@ -1724,13 +1711,13 @@ a b [G] [E] [L] cmpBasis Function Combinator
Same as not a.
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
-Lorem ipsum.
Lorem ipsum.
@@ -1746,20 +1733,20 @@ 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.
Lorem ipsum.
@@ -1770,16 +1757,16 @@ a b [G] [E] [L] cmp ... [P] nullary
---------------------
... A
-[stack] dip infra first
-... [P] nullary
... [P] [stack] dip infra first
... stack [P] infra first
... [...] [P] infra first
... [A ...] first
... A
-A very useful function that runs any other quoted function and returns it’s first result without disturbing the stack (under the quoted program.)
Basis Function Combinator
swap at
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
-Lorem ipsum.
Lorem ipsum.
@@ -1803,13 +1790,13 @@ a b [G] [E] [L] cmpBasis Function Combinator
Same as a | b.
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
-Lorem ipsum.
Lorem ipsum.
@@ -1818,13 +1805,13 @@ a b [G] [E] [L] cmpBasis Function Combinator
(a2 a1 -- a2 a1 a2)
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
-Lorem ipsum.
Lorem ipsum.
@@ -1833,13 +1820,13 @@ a b [G] [E] [L] cmpBasis Function Combinator
[i] map
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
-Lorem ipsum.
Lorem ipsum.
@@ -1854,13 +1841,13 @@ a b [G] [E] [L] cmp ------------- a+b a-bGentzen diagram.
-if not basis.
-if not basis.
-if basis
-Lorem ipsum.
Lorem ipsum.
@@ -1869,13 +1856,13 @@ a+b a-bBasis Function Combinator
(a1 --)
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
-Lorem ipsum.
Lorem ipsum.
@@ -1884,13 +1871,13 @@ a+b a-bBasis Function Combinator
(a2 a1 -- a1)
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
-Lorem ipsum.
Lorem ipsum.
@@ -1899,13 +1886,13 @@ a+b a-bBasis Function Combinator
(a3 a2 a1 -- a2 a1)
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
-Lorem ipsum.
Lorem ipsum.
@@ -1914,13 +1901,13 @@ a+b a-bBasis Function Combinator
(a2 a1 --)
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
-Lorem ipsum.
Lorem ipsum.
@@ -1929,13 +1916,13 @@ a+b a-bBasis Function Combinator
(a3 a2 a1 -- a1)
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
-Lorem ipsum.
Lorem ipsum.
@@ -1944,13 +1931,13 @@ a+b a-bBasis Function Combinator
(a4 a3 a2 a1 -- a2 a1)
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
-Lorem ipsum.
Lorem ipsum.
@@ -1959,13 +1946,13 @@ a+b a-bBasis Function Combinator
pop popop
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
-Lorem ipsum.
Lorem ipsum.
@@ -1974,13 +1961,13 @@ a+b a-bBasis Function Combinator
Same as a ** b.
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
-Lorem ipsum.
Lorem ipsum.
@@ -1989,13 +1976,13 @@ a+b a-bBasis Function Combinator
Decrement TOS.
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
-Lorem ipsum.
Lorem ipsum.
@@ -2016,13 +2003,13 @@ a+b a-b ------------------------------------------ n > 0 n (n-1) [Base] [Recur] primrec RecurGentzen diagram.
-if not basis.
-if not basis.
-if basis
-Lorem ipsum.
Lorem ipsum.
@@ -2031,13 +2018,13 @@ a+b a-bBasis Function Combinator
1 swap [*] step
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
-Lorem ipsum.
Lorem ipsum.
@@ -2046,13 +2033,13 @@ a+b a-bBasis Function Combinator
[unit] dip
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
-Lorem ipsum.
Lorem ipsum.
@@ -2061,13 +2048,13 @@ a+b a-bBasis Function Combinator
[0 <=] [1 - dup] anamorphism
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
-Lorem ipsum.
Lorem ipsum.
@@ -2076,13 +2063,13 @@ a+b a-bBasis Function Combinator
unit [down_to_zero] infra
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
-Lorem ipsum.
Lorem ipsum.
@@ -2091,13 +2078,13 @@ a+b a-bBasis Function Combinator
rest cons
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
-Lorem ipsum.
Lorem ipsum.
@@ -2115,13 +2102,13 @@ a+b a-b ------------------------ [2 3 1]Gentzen diagram.
-if not basis.
-if not basis.
-if basis
-Lorem ipsum.
Lorem ipsum.
@@ -2130,13 +2117,13 @@ a+b a-bBasis Function Combinator
([a1 ...0] -- [...0])
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
-Lorem ipsum.
Lorem ipsum.
@@ -2146,13 +2133,13 @@ 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.
Lorem ipsum.
@@ -2161,13 +2148,13 @@ a+b a-bBasis Function Combinator
(a1 a2 a3 -- a2 a3 a1)
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
-Lorem ipsum.
Lorem ipsum.
@@ -2176,13 +2163,13 @@ a+b a-bBasis Function Combinator
(a1 a2 a3 -- a3 a1 a2)
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
-Lorem ipsum.
Lorem ipsum.
@@ -2198,13 +2185,13 @@ 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.
Lorem ipsum.
@@ -2213,13 +2200,13 @@ a+b a-bBasis Function Combinator
([a1 a2 ...1] -- [...1])
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
-Lorem ipsum.
Lorem ipsum.
@@ -2228,13 +2215,13 @@ a+b a-bBasis Function Combinator
Same as a >> b.
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
-Lorem ipsum.
Lorem ipsum.
@@ -2243,13 +2230,13 @@ a+b a-bBasis Function Combinator
<{} infra
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
-Lorem ipsum.
Lorem ipsum.
@@ -2258,13 +2245,13 @@ a+b a-bBasis Function Combinator
([a1 a2 ...1] -- a2)
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
-Lorem ipsum.
Lorem ipsum.
@@ -2282,13 +2269,13 @@ 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.
Lorem ipsum.
@@ -2297,13 +2284,13 @@ a+b a-bBasis Function Combinator
Print redistribution information.
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
-Lorem ipsum.
Lorem ipsum.
@@ -2312,13 +2299,13 @@ a+b a-bBasis Function Combinator
uncons [swons] dip
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
-Lorem ipsum.
Lorem ipsum.
@@ -2332,13 +2319,13 @@ a+b a-b --------------------------- [f e d a b c]Gentzen diagram.
-if not basis.
-if not basis.
-if basis
-Lorem ipsum.
Lorem ipsum.
@@ -2347,13 +2334,13 @@ a+b a-bBasis Function Combinator
[pop ++] step_zero
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
-Lorem ipsum.
Lorem ipsum.
@@ -2362,13 +2349,13 @@ a+b a-bBasis Function Combinator
Given a list return it sorted.
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
-Lorem ipsum.
Lorem ipsum.
@@ -2377,13 +2364,13 @@ 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.
Lorem ipsum.
@@ -2392,13 +2379,13 @@ a+b a-bBasis Function Combinator
[drop] [take] clop
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
-Lorem ipsum.
Lorem ipsum.
@@ -2407,13 +2394,13 @@ a+b a-bBasis Function Combinator
[take reverse] [drop] clop
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
-Lorem ipsum.
Lorem ipsum.
@@ -2422,13 +2409,13 @@ a+b a-bBasis Function Combinator
dup *
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
-Lorem ipsum.
Lorem ipsum.
@@ -2437,13 +2424,13 @@ 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.
Lorem ipsum.
@@ -2452,13 +2439,13 @@ a+b a-bBasis Function Combinator
(... -- ... [...])
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
-Lorem ipsum.
Lorem ipsum.
@@ -2467,13 +2454,13 @@ a+b a-bBasis Function Combinator
[stack] dip
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
-Lorem ipsum.
Lorem ipsum.
@@ -2496,13 +2483,13 @@ 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.
Lorem ipsum.
@@ -2511,13 +2498,13 @@ a+b a-bBasis Function Combinator
0 roll> step
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
-Lorem ipsum.
Lorem ipsum.
@@ -2526,13 +2513,13 @@ a+b a-bBasis Function Combinator
(... a1 -- ... a1 a1 [...])
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
-Lorem ipsum.
Lorem ipsum.
@@ -2541,13 +2528,13 @@ a+b a-bBasis Function Combinator
(... a2 a1 -- ... a2 a1 a1 a2 [...])
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
-Lorem ipsum.
Lorem ipsum.
@@ -2556,13 +2543,13 @@ a+b a-bBasis Function Combinator
Same as a - b.
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
-Lorem ipsum.
Lorem ipsum.
@@ -2571,13 +2558,13 @@ a+b a-bBasis Function Combinator
Increment TOS.
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
-Lorem ipsum.
Lorem ipsum.
@@ -2587,13 +2574,13 @@ 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.
Lorem ipsum.
@@ -2602,13 +2589,13 @@ a+b a-bBasis Function Combinator
([...1] -- [...0])
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
-Lorem ipsum.
Lorem ipsum.
@@ -2617,13 +2604,13 @@ a+b a-bBasis Function Combinator
(a1 a2 -- a2 a1)
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
-Lorem ipsum.
Lorem ipsum.
@@ -2632,13 +2619,13 @@ a+b a-bBasis Function Combinator
[swap] dip
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
-Lorem ipsum.
Lorem ipsum.
@@ -2647,13 +2634,13 @@ a+b a-bBasis Function Combinator
swap concat
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
-Lorem ipsum.
Lorem ipsum.
@@ -2662,13 +2649,13 @@ a+b a-bBasis Function Combinator
([...1] a1 -- [a1 ...1])
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
-Lorem ipsum.
Lorem ipsum.
@@ -2677,13 +2664,13 @@ a+b a-bBasis Function Combinator
[i] genrec
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
-Lorem ipsum.
Lorem ipsum.
@@ -2695,13 +2682,13 @@ a+b a-b ---------------------- [b a]Gentzen diagram.
-if not basis.
-if not basis.
-if basis
-Lorem ipsum.
Lorem ipsum.
@@ -2712,9 +2699,9 @@ 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.
Basis Function Combinator
([a1 a2 a3 ...1] -- a3)
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
-Lorem ipsum.
Lorem ipsum.
@@ -2751,13 +2738,13 @@ a+b a-b ------------------------------------- w/ n > 1 ... . Q (n - 1) [Q] timesGentzen diagram.
-if not basis.
-if not basis.
-if basis
-Lorem ipsum.
Lorem ipsum.
@@ -2769,13 +2756,13 @@ a+b a-bBasis Function Combinator
(a2 a1 -- a1 a2 a1)
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
-Lorem ipsum.
Lorem ipsum.
@@ -2786,9 +2773,9 @@ 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.
[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.
Lorem ipsum.
@@ -2825,13 +2812,13 @@ a+b a-bBasis Function Combinator
(a1 -- [a1 ])
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
-Lorem ipsum.
Lorem ipsum.
@@ -2840,13 +2827,13 @@ a+b a-bBasis Function Combinator
[i] dip
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
-Lorem ipsum.
Lorem ipsum.
@@ -2855,13 +2842,13 @@ a+b a-bBasis Function Combinator
([a1 ...1] -- [...1] a1)
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
-Lorem ipsum.
Lorem ipsum.
@@ -2870,13 +2857,13 @@ 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.
Lorem ipsum.
@@ -2885,13 +2872,13 @@ a+b a-bBasis Function Combinator
Print warranty information.
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
-Lorem ipsum.
Lorem ipsum.
@@ -2900,13 +2887,13 @@ a+b a-bBasis Function Combinator
swap nulco dupdipd concat loop
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
-Lorem ipsum.
Lorem ipsum.
@@ -2915,13 +2902,13 @@ 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.
Lorem ipsum.
@@ -2931,22 +2918,22 @@ 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.
Lorem ipsum.
@@ -2955,13 +2942,13 @@ 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.
Lorem ipsum.
diff --git a/docs/reference/mkref/Functor-Reference.md b/docs/reference/mkref/Functor-Reference.md index f1d79ba..64ec5c2 100644 --- a/docs/reference/mkref/Functor-Reference.md +++ b/docs/reference/mkref/Functor-Reference.md @@ -671,267 +671,225 @@ terms of [choice] as above). The more common "if..then..else" construct ## ccccons -Basis Function Combinator +Function -ccons ccons + a b c d [...] ccccons + --------------------------- + [a b c d ...] -Gentzen diagram. +Do [cons] four times. ### Definition -if not basis. - -### Derivation - -if not basis. - -### Source - -if basis - -### Discussion - -Lorem ipsum. +> [ccons] [ccons] ### Crosslinks -Lorem ipsum. +[ccons] [cons] [times] + -------------------- ## ccons -(Function) +Function -Given two items and a list, append the items to the list to make a new list. - - B A [...] ccons + a b [...] ccons --------------------- - [B A ...] + [a b ...] + +Do [cons] two times. ### Definition - cons cons - -### Discussion - -Does `cons` twice. +> [cons] [cons] ### Crosslinks -[cons](#cons) +[cons] +[ccons] ------------------------------------------------------------------------ ## choice -Basis Function Combinator +Basis Function -Use a Boolean value to select one of two items. : +Use a Boolean value to select one of two items. - A B false choice + a b false choice ---------------------- - A + a - - A B true choice + a b true choice --------------------- - B - -Currently Python semantics are used to evaluate the \"truthiness\" of -the Boolean value (so empty string, zero, etc. are counted as false, -etc.) - -Gentzen diagram. + b ### Definition -if not basis. - -### Derivation - -if not basis. - -### Source - -if basis +> \[[pop]\] \[[popd]\] [branch] ### Discussion -Lorem ipsum. +It's a matter of taste whether you implement this in terms of [branch] or +the other way around. ### Crosslinks -Lorem ipsum. +[branch] +[select] + ------------------------------------------------------------------------ ## clear -Basis Function Combinator +Basis Function Clear everything from the stack. -: clear == stack [pop stack] loop - - ... clear - --------------- - -Gentzen diagram. - ### Definition -if not basis. - -### Derivation - -if not basis. - -### Source - -if basis - -### Discussion - -Lorem ipsum. +> [stack] [bool] \[[pop] [stack] [bool]\] [loop] ### Crosslinks -Lorem ipsum. +[stack] +[swaack] + ------------------------------------------------------------------------ ## cleave -Basis Function Combinator +Combinator -fork popdd +Run two programs in parallel, consuming one additional item, and put their +results on the stack. -Gentzen diagram. - -### Definition - -if not basis. + ... x [A] [B] cleave + ------------------------ + ... a b ### Derivation -if not basis. +> [fork] [popdd] -### Source +### Example -if basis + 1 2 3 [+] [-] cleave + -------------------------- + 1 2 5 -1 ### Discussion -Lorem ipsum. +One of a handful of useful parallel combinators. ### Crosslinks -Lorem ipsum. +[clop] +[fork] +[map] + ------------------------------------------------------------------------ ## clop -Basis Function Combinator +Combinator -cleave popdd +Run two programs in parallel, consuming two additional items, and put their results on the stack. -Gentzen diagram. + ... x y [A] [B] clop + -------------------------- + ... a b ### Definition -if not basis. - -### Derivation - -if not basis. - -### Source - -if basis +> [cleave] [popdd] ### Discussion -Lorem ipsum. +Like [cleave] but consumes an additional item from the stack. + + 1 2 3 4 [+] [-] clop + -------------------------- + 1 2 7 -1 ### Crosslinks -Lorem ipsum. +[cleave] +[fork] +[map] + ------------------------------------------------------------------------ ## cmp -Basis Function Combinator +Combinator -cmp takes two values and three quoted programs on the stack and runs one -of the three depending on the results of comparing the two values: : +Take two values and three quoted programs on the stack and run one +of the three depending on the results of comparing the two values. - a b [G] [E] [L] cmp + a b [G] [E] [L] cmp ------------------------- a > b - G + G - a b [G] [E] [L] cmp + a b [G] [E] [L] cmp ------------------------- a = b - E + E - a b [G] [E] [L] cmp + a b [G] [E] [L] cmp ------------------------- a < b - L - -Gentzen diagram. - -### Definition - -if not basis. - -### Derivation - -if not basis. - -### Source - -if basis - + L ### Discussion -Lorem ipsum. +This is useful sometimes, and you can [dup] or [dupd] with two quoted +programs to handle the cases when you just want to deal with [<=] or [>=] +and not all three possibilities, e.g.: + + [G] [LE] dup cmp + + [GE] [L] dupd cmp + +Or even: + + [GL] [E] over cmp ### Crosslinks -Lorem ipsum. +TODO: link to tree notebooks where this was used. + ------------------------------------------------------------------------ ## codi -Basis Function Combinator +Combinator -cons dip - -Gentzen diagram. +Take a quoted program from the stack, [cons] the next item onto it, then +[dip] the whole thing under what was the third item on the stack. + + a b [F] . codi + -------------------- + b . F a ### Definition -if not basis. - -### Derivation - -if not basis. - -### Source - -if basis +> [cons] [dip] ### Discussion -Lorem ipsum. +This is one of those weirdly specific functions that turns out to be +useful in a few places. ### Crosslinks -Lorem ipsum. +[appN] +[codireco] + ------------------------------------------------------------------------ diff --git a/implementations/Python/joy/library.py b/implementations/Python/joy/library.py index b343c9b..c5d17ce 100644 --- a/implementations/Python/joy/library.py +++ b/implementations/Python/joy/library.py @@ -340,10 +340,9 @@ def choice(stack): --------------------- B - Currently Python semantics are used to evaluate the "truthiness" of the - Boolean value (so empty string, zero, etc. are counted as false, etc.) ''' (if_, (then, (else_, stack))) = stack + assert isinstance(if_, bool), repr(if_) return then if if_ else else_, stack