Most of the C's.
This commit is contained in:
parent
43649685ac
commit
9057e3b347
|
|
@ -2,28 +2,19 @@
|
||||||
|
|
||||||
## ccccons
|
## ccccons
|
||||||
|
|
||||||
Basis Function Combinator
|
Function
|
||||||
|
|
||||||
ccons ccons
|
a b c d [...] ccccons
|
||||||
|
---------------------------
|
||||||
|
[a b c d ...]
|
||||||
|
|
||||||
Gentzen diagram.
|
Do [cons] four times.
|
||||||
|
|
||||||
### Definition
|
### Definition
|
||||||
|
|
||||||
if not basis.
|
> [ccons] [ccons]
|
||||||
|
|
||||||
### Derivation
|
|
||||||
|
|
||||||
if not basis.
|
|
||||||
|
|
||||||
### Source
|
|
||||||
|
|
||||||
if basis
|
|
||||||
|
|
||||||
### Discussion
|
|
||||||
|
|
||||||
Lorem ipsum.
|
|
||||||
|
|
||||||
### Crosslinks
|
### Crosslinks
|
||||||
|
|
||||||
Lorem ipsum.
|
[ccons] [cons] [times]
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,23 +2,20 @@
|
||||||
|
|
||||||
## ccons
|
## ccons
|
||||||
|
|
||||||
(Function)
|
Function
|
||||||
|
|
||||||
Given two items and a list, append the items to the list to make a new list.
|
a b [...] ccons
|
||||||
|
|
||||||
B A [...] ccons
|
|
||||||
---------------------
|
---------------------
|
||||||
[B A ...]
|
[a b ...]
|
||||||
|
|
||||||
|
Do [cons] two times.
|
||||||
|
|
||||||
### Definition
|
### Definition
|
||||||
|
|
||||||
cons cons
|
> [cons] [cons]
|
||||||
|
|
||||||
### Discussion
|
|
||||||
|
|
||||||
Does `cons` twice.
|
|
||||||
|
|
||||||
### Crosslinks
|
### Crosslinks
|
||||||
|
|
||||||
[cons](#cons)
|
[cons]
|
||||||
|
[ccons]
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,41 +2,29 @@
|
||||||
|
|
||||||
## choice
|
## 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
|
b
|
||||||
|
|
||||||
Currently Python semantics are used to evaluate the \"truthiness\" of
|
|
||||||
the Boolean value (so empty string, zero, etc. are counted as false,
|
|
||||||
etc.)
|
|
||||||
|
|
||||||
Gentzen diagram.
|
|
||||||
|
|
||||||
### Definition
|
### Definition
|
||||||
|
|
||||||
if not basis.
|
> \[[pop]\] \[[popd]\] [branch]
|
||||||
|
|
||||||
### Derivation
|
|
||||||
|
|
||||||
if not basis.
|
|
||||||
|
|
||||||
### Source
|
|
||||||
|
|
||||||
if basis
|
|
||||||
|
|
||||||
### Discussion
|
### Discussion
|
||||||
|
|
||||||
Lorem ipsum.
|
It's a matter of taste whether you implement this in terms of [branch] or
|
||||||
|
the other way around.
|
||||||
|
|
||||||
### Crosslinks
|
### Crosslinks
|
||||||
|
|
||||||
Lorem ipsum.
|
[branch]
|
||||||
|
[select]
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,33 +2,16 @@
|
||||||
|
|
||||||
## clear
|
## clear
|
||||||
|
|
||||||
Basis Function Combinator
|
Basis Function
|
||||||
|
|
||||||
Clear everything from the stack.
|
Clear everything from the stack.
|
||||||
|
|
||||||
: clear == stack [pop stack] loop
|
|
||||||
|
|
||||||
... clear
|
|
||||||
---------------
|
|
||||||
|
|
||||||
Gentzen diagram.
|
|
||||||
|
|
||||||
### Definition
|
### Definition
|
||||||
|
|
||||||
if not basis.
|
> [stack] [bool] \[[pop] [stack] [bool]\] [loop]
|
||||||
|
|
||||||
### Derivation
|
|
||||||
|
|
||||||
if not basis.
|
|
||||||
|
|
||||||
### Source
|
|
||||||
|
|
||||||
if basis
|
|
||||||
|
|
||||||
### Discussion
|
|
||||||
|
|
||||||
Lorem ipsum.
|
|
||||||
|
|
||||||
### Crosslinks
|
### Crosslinks
|
||||||
|
|
||||||
Lorem ipsum.
|
[stack]
|
||||||
|
[swaack]
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,28 +2,32 @@
|
||||||
|
|
||||||
## cleave
|
## 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.
|
... x [A] [B] cleave
|
||||||
|
------------------------
|
||||||
### Definition
|
... a b
|
||||||
|
|
||||||
if not basis.
|
|
||||||
|
|
||||||
### Derivation
|
### Derivation
|
||||||
|
|
||||||
if not basis.
|
> [fork] [popdd]
|
||||||
|
|
||||||
### Source
|
### Example
|
||||||
|
|
||||||
if basis
|
1 2 3 [+] [-] cleave
|
||||||
|
--------------------------
|
||||||
|
1 2 5 -1
|
||||||
|
|
||||||
### Discussion
|
### Discussion
|
||||||
|
|
||||||
Lorem ipsum.
|
One of a handful of useful parallel combinators.
|
||||||
|
|
||||||
### Crosslinks
|
### Crosslinks
|
||||||
|
|
||||||
Lorem ipsum.
|
[clop]
|
||||||
|
[fork]
|
||||||
|
[map]
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,28 +2,29 @@
|
||||||
|
|
||||||
## clop
|
## 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
|
### Definition
|
||||||
|
|
||||||
if not basis.
|
> [cleave] [popdd]
|
||||||
|
|
||||||
### Derivation
|
|
||||||
|
|
||||||
if not basis.
|
|
||||||
|
|
||||||
### Source
|
|
||||||
|
|
||||||
if basis
|
|
||||||
|
|
||||||
### Discussion
|
### Discussion
|
||||||
|
|
||||||
Lorem ipsum.
|
Like [cleave] but consumes an additional item from the stack.
|
||||||
|
|
||||||
|
1 2 3 4 [+] [-] clop
|
||||||
|
--------------------------
|
||||||
|
1 2 7 -1
|
||||||
|
|
||||||
### Crosslinks
|
### Crosslinks
|
||||||
|
|
||||||
Lorem ipsum.
|
[cleave]
|
||||||
|
[fork]
|
||||||
|
[map]
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,41 +2,37 @@
|
||||||
|
|
||||||
## cmp
|
## cmp
|
||||||
|
|
||||||
Basis Function Combinator
|
Combinator
|
||||||
|
|
||||||
cmp takes two values and three quoted programs on the stack and runs one
|
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: :
|
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
|
------------------------- a > b
|
||||||
G
|
G
|
||||||
|
|
||||||
a b [G] [E] [L] cmp
|
a b [G] [E] [L] cmp
|
||||||
------------------------- a = b
|
------------------------- a = b
|
||||||
E
|
E
|
||||||
|
|
||||||
a b [G] [E] [L] cmp
|
a b [G] [E] [L] cmp
|
||||||
------------------------- a < b
|
------------------------- a < b
|
||||||
L
|
L
|
||||||
|
|
||||||
Gentzen diagram.
|
|
||||||
|
|
||||||
### Definition
|
|
||||||
|
|
||||||
if not basis.
|
|
||||||
|
|
||||||
### Derivation
|
|
||||||
|
|
||||||
if not basis.
|
|
||||||
|
|
||||||
### Source
|
|
||||||
|
|
||||||
if basis
|
|
||||||
|
|
||||||
### Discussion
|
### 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
|
### Crosslinks
|
||||||
|
|
||||||
Lorem ipsum.
|
TODO: link to tree notebooks where this was used.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,28 +2,26 @@
|
||||||
|
|
||||||
## codi
|
## codi
|
||||||
|
|
||||||
Basis Function Combinator
|
Combinator
|
||||||
|
|
||||||
cons dip
|
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.
|
||||||
Gentzen diagram.
|
|
||||||
|
a b [F] . codi
|
||||||
|
--------------------
|
||||||
|
b . F a
|
||||||
|
|
||||||
### Definition
|
### Definition
|
||||||
|
|
||||||
if not basis.
|
> [cons] [dip]
|
||||||
|
|
||||||
### Derivation
|
|
||||||
|
|
||||||
if not basis.
|
|
||||||
|
|
||||||
### Source
|
|
||||||
|
|
||||||
if basis
|
|
||||||
|
|
||||||
### Discussion
|
### Discussion
|
||||||
|
|
||||||
Lorem ipsum.
|
This is one of those weirdly specific functions that turns out to be
|
||||||
|
useful in a few places.
|
||||||
|
|
||||||
### Crosslinks
|
### Crosslinks
|
||||||
|
|
||||||
Lorem ipsum.
|
[appN]
|
||||||
|
[codireco]
|
||||||
|
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load Diff
|
|
@ -671,267 +671,225 @@ terms of [choice] as above). The more common "if..then..else" construct
|
||||||
|
|
||||||
## ccccons
|
## ccccons
|
||||||
|
|
||||||
Basis Function Combinator
|
Function
|
||||||
|
|
||||||
ccons ccons
|
a b c d [...] ccccons
|
||||||
|
---------------------------
|
||||||
|
[a b c d ...]
|
||||||
|
|
||||||
Gentzen diagram.
|
Do [cons] four times.
|
||||||
|
|
||||||
### Definition
|
### Definition
|
||||||
|
|
||||||
if not basis.
|
> [ccons] [ccons]
|
||||||
|
|
||||||
### Derivation
|
|
||||||
|
|
||||||
if not basis.
|
|
||||||
|
|
||||||
### Source
|
|
||||||
|
|
||||||
if basis
|
|
||||||
|
|
||||||
### Discussion
|
|
||||||
|
|
||||||
Lorem ipsum.
|
|
||||||
|
|
||||||
### Crosslinks
|
### Crosslinks
|
||||||
|
|
||||||
Lorem ipsum.
|
[ccons] [cons] [times]
|
||||||
|
|
||||||
|
|
||||||
--------------------
|
--------------------
|
||||||
|
|
||||||
## ccons
|
## ccons
|
||||||
|
|
||||||
(Function)
|
Function
|
||||||
|
|
||||||
Given two items and a list, append the items to the list to make a new list.
|
a b [...] ccons
|
||||||
|
|
||||||
B A [...] ccons
|
|
||||||
---------------------
|
---------------------
|
||||||
[B A ...]
|
[a b ...]
|
||||||
|
|
||||||
|
Do [cons] two times.
|
||||||
|
|
||||||
### Definition
|
### Definition
|
||||||
|
|
||||||
cons cons
|
> [cons] [cons]
|
||||||
|
|
||||||
### Discussion
|
|
||||||
|
|
||||||
Does `cons` twice.
|
|
||||||
|
|
||||||
### Crosslinks
|
### Crosslinks
|
||||||
|
|
||||||
[cons](#cons)
|
[cons]
|
||||||
|
[ccons]
|
||||||
|
|
||||||
|
|
||||||
------------------------------------------------------------------------
|
------------------------------------------------------------------------
|
||||||
|
|
||||||
## choice
|
## 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
|
b
|
||||||
|
|
||||||
Currently Python semantics are used to evaluate the \"truthiness\" of
|
|
||||||
the Boolean value (so empty string, zero, etc. are counted as false,
|
|
||||||
etc.)
|
|
||||||
|
|
||||||
Gentzen diagram.
|
|
||||||
|
|
||||||
### Definition
|
### Definition
|
||||||
|
|
||||||
if not basis.
|
> \[[pop]\] \[[popd]\] [branch]
|
||||||
|
|
||||||
### Derivation
|
|
||||||
|
|
||||||
if not basis.
|
|
||||||
|
|
||||||
### Source
|
|
||||||
|
|
||||||
if basis
|
|
||||||
|
|
||||||
### Discussion
|
### Discussion
|
||||||
|
|
||||||
Lorem ipsum.
|
It's a matter of taste whether you implement this in terms of [branch] or
|
||||||
|
the other way around.
|
||||||
|
|
||||||
### Crosslinks
|
### Crosslinks
|
||||||
|
|
||||||
Lorem ipsum.
|
[branch]
|
||||||
|
[select]
|
||||||
|
|
||||||
|
|
||||||
------------------------------------------------------------------------
|
------------------------------------------------------------------------
|
||||||
|
|
||||||
## clear
|
## clear
|
||||||
|
|
||||||
Basis Function Combinator
|
Basis Function
|
||||||
|
|
||||||
Clear everything from the stack.
|
Clear everything from the stack.
|
||||||
|
|
||||||
: clear == stack [pop stack] loop
|
|
||||||
|
|
||||||
... clear
|
|
||||||
---------------
|
|
||||||
|
|
||||||
Gentzen diagram.
|
|
||||||
|
|
||||||
### Definition
|
### Definition
|
||||||
|
|
||||||
if not basis.
|
> [stack] [bool] \[[pop] [stack] [bool]\] [loop]
|
||||||
|
|
||||||
### Derivation
|
|
||||||
|
|
||||||
if not basis.
|
|
||||||
|
|
||||||
### Source
|
|
||||||
|
|
||||||
if basis
|
|
||||||
|
|
||||||
### Discussion
|
|
||||||
|
|
||||||
Lorem ipsum.
|
|
||||||
|
|
||||||
### Crosslinks
|
### Crosslinks
|
||||||
|
|
||||||
Lorem ipsum.
|
[stack]
|
||||||
|
[swaack]
|
||||||
|
|
||||||
|
|
||||||
------------------------------------------------------------------------
|
------------------------------------------------------------------------
|
||||||
|
|
||||||
## cleave
|
## 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.
|
... x [A] [B] cleave
|
||||||
|
------------------------
|
||||||
### Definition
|
... a b
|
||||||
|
|
||||||
if not basis.
|
|
||||||
|
|
||||||
### Derivation
|
### Derivation
|
||||||
|
|
||||||
if not basis.
|
> [fork] [popdd]
|
||||||
|
|
||||||
### Source
|
### Example
|
||||||
|
|
||||||
if basis
|
1 2 3 [+] [-] cleave
|
||||||
|
--------------------------
|
||||||
|
1 2 5 -1
|
||||||
|
|
||||||
### Discussion
|
### Discussion
|
||||||
|
|
||||||
Lorem ipsum.
|
One of a handful of useful parallel combinators.
|
||||||
|
|
||||||
### Crosslinks
|
### Crosslinks
|
||||||
|
|
||||||
Lorem ipsum.
|
[clop]
|
||||||
|
[fork]
|
||||||
|
[map]
|
||||||
|
|
||||||
|
|
||||||
------------------------------------------------------------------------
|
------------------------------------------------------------------------
|
||||||
|
|
||||||
## clop
|
## 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
|
### Definition
|
||||||
|
|
||||||
if not basis.
|
> [cleave] [popdd]
|
||||||
|
|
||||||
### Derivation
|
|
||||||
|
|
||||||
if not basis.
|
|
||||||
|
|
||||||
### Source
|
|
||||||
|
|
||||||
if basis
|
|
||||||
|
|
||||||
### Discussion
|
### Discussion
|
||||||
|
|
||||||
Lorem ipsum.
|
Like [cleave] but consumes an additional item from the stack.
|
||||||
|
|
||||||
|
1 2 3 4 [+] [-] clop
|
||||||
|
--------------------------
|
||||||
|
1 2 7 -1
|
||||||
|
|
||||||
### Crosslinks
|
### Crosslinks
|
||||||
|
|
||||||
Lorem ipsum.
|
[cleave]
|
||||||
|
[fork]
|
||||||
|
[map]
|
||||||
|
|
||||||
|
|
||||||
------------------------------------------------------------------------
|
------------------------------------------------------------------------
|
||||||
|
|
||||||
## cmp
|
## cmp
|
||||||
|
|
||||||
Basis Function Combinator
|
Combinator
|
||||||
|
|
||||||
cmp takes two values and three quoted programs on the stack and runs one
|
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: :
|
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
|
------------------------- a > b
|
||||||
G
|
G
|
||||||
|
|
||||||
a b [G] [E] [L] cmp
|
a b [G] [E] [L] cmp
|
||||||
------------------------- a = b
|
------------------------- a = b
|
||||||
E
|
E
|
||||||
|
|
||||||
a b [G] [E] [L] cmp
|
a b [G] [E] [L] cmp
|
||||||
------------------------- a < b
|
------------------------- a < b
|
||||||
L
|
L
|
||||||
|
|
||||||
Gentzen diagram.
|
|
||||||
|
|
||||||
### Definition
|
|
||||||
|
|
||||||
if not basis.
|
|
||||||
|
|
||||||
### Derivation
|
|
||||||
|
|
||||||
if not basis.
|
|
||||||
|
|
||||||
### Source
|
|
||||||
|
|
||||||
if basis
|
|
||||||
|
|
||||||
### Discussion
|
### 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
|
### Crosslinks
|
||||||
|
|
||||||
Lorem ipsum.
|
TODO: link to tree notebooks where this was used.
|
||||||
|
|
||||||
|
|
||||||
------------------------------------------------------------------------
|
------------------------------------------------------------------------
|
||||||
|
|
||||||
## codi
|
## codi
|
||||||
|
|
||||||
Basis Function Combinator
|
Combinator
|
||||||
|
|
||||||
cons dip
|
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.
|
||||||
Gentzen diagram.
|
|
||||||
|
a b [F] . codi
|
||||||
|
--------------------
|
||||||
|
b . F a
|
||||||
|
|
||||||
### Definition
|
### Definition
|
||||||
|
|
||||||
if not basis.
|
> [cons] [dip]
|
||||||
|
|
||||||
### Derivation
|
|
||||||
|
|
||||||
if not basis.
|
|
||||||
|
|
||||||
### Source
|
|
||||||
|
|
||||||
if basis
|
|
||||||
|
|
||||||
### Discussion
|
### Discussion
|
||||||
|
|
||||||
Lorem ipsum.
|
This is one of those weirdly specific functions that turns out to be
|
||||||
|
useful in a few places.
|
||||||
|
|
||||||
### Crosslinks
|
### Crosslinks
|
||||||
|
|
||||||
Lorem ipsum.
|
[appN]
|
||||||
|
[codireco]
|
||||||
|
|
||||||
|
|
||||||
------------------------------------------------------------------------
|
------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -340,10 +340,9 @@ def choice(stack):
|
||||||
---------------------
|
---------------------
|
||||||
B
|
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
|
(if_, (then, (else_, stack))) = stack
|
||||||
|
assert isinstance(if_, bool), repr(if_)
|
||||||
return then if if_ else else_, stack
|
return then if if_ else else_, stack
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue