Great progress!

This commit is contained in:
sforman 2023-10-08 20:17:02 -07:00
parent eb665f2b50
commit 04d3e96a99
4 changed files with 182 additions and 220 deletions

File diff suppressed because one or more lines are too long

View File

@ -6,6 +6,30 @@ Version -10.0.0
Each function, combinator, or definition should be documented here. Each function, combinator, or definition should be documented here.
------------------------------------------------------------------------
## /\
Binary Boolean *and*.
### Crosslinks
[bool]
[not]
[\/]
------------------------------------------------------------------------
## \/
Binary Boolean *or*.
### Crosslinks
[bool]
[not]
[/\]
------------------------------------------------------------------------ ------------------------------------------------------------------------
## abs ## abs
@ -390,13 +414,6 @@ the other way around.
[select] [select]
--------------
## ^
See [xor](#xor).
------------------------------------------------------------------------ ------------------------------------------------------------------------
## clear ## clear
@ -648,13 +665,38 @@ Specialist function (that means I forgot what it does and why.)
------------------------------------------------------------------------ ------------------------------------------------------------------------
## dipddd
Combinator
Like [dip] but expects four items. :
... z y x w [Q] . dipddd
-------------------------------
... . Q z y x w
### Discussion
See [dip].
### Crosslinks
[dip]
[dipd]
[dipdd]
[dupdip]
[dupdipd]
[infra]
------------------------------------------------------------------------
## dipdd ## dipdd
Combinator Combinator
Like [dip] but expects three items. : Like [dip] but expects three items. :
... z y x [Q] . dip ... z y x [Q] . dipdd
----------------------------- -----------------------------
... . Q z y x ... . Q z y x
### Discussion ### Discussion
@ -665,11 +707,11 @@ See [dip].
[dip] [dip]
[dipd] [dipd]
[dipddd]
[dupdip] [dupdip]
[dupdipd] [dupdipd]
[infra] [infra]
------------------------------------------------------------------------ ------------------------------------------------------------------------
## dipd ## dipd
@ -690,6 +732,7 @@ See [dip].
[dip] [dip]
[dipdd] [dipdd]
[dipddd]
[dupdip] [dupdip]
[dupdipd] [dupdipd]
[infra] [infra]
@ -755,13 +798,13 @@ printed with the top or head on the left.
[enstacken] [enstacken]
[stack] [stack]
[unstack]
--------------------------------------------
--------------
## div ## div
See [floordiv](#floordiv). Divide.
------------------------------------------------------------------------ ------------------------------------------------------------------------
@ -933,6 +976,7 @@ This is a destructive version of [stack]. See the note under
[stack] [stack]
[disenstacken] [disenstacken]
[unstack]
------------------------------------------------------------------------ ------------------------------------------------------------------------
@ -954,7 +998,7 @@ them with a Boolean value.
[gt] [gt]
[le] [le]
[lt] [lt]
[ne] [neq]
-------------- --------------
@ -968,7 +1012,7 @@ See [eq](#eq).
## != ## !=
See [ne](#ne). See [neq](#neq).
------------------------------------------------------------------------ ------------------------------------------------------------------------
@ -1071,39 +1115,6 @@ Note that only one "level" of lists is flattened. In the example above
[zip] [zip]
------------------------------------------------------------------------
## floordiv
I don't know why this is called "floor" div, I think it rounds its
result down (not towards zero or up.)
a b floordiv
------------------
(a/b)
### Discussion
All the division commands need to be revisited when the "numeric tower"
for Thun gets nailed down.
### Crosslinks
[divmod]
------------------------------------------------------------------------
## floor
Return the largest integer \<= x.
### Discussion
This function doesn't make sense (yet) to have because there are (as yet)
only integers in the system.
------------------------------------------------------------------------ ------------------------------------------------------------------------
## fork ## fork
@ -1145,21 +1156,6 @@ Replace a list with its fourth item.
[rest] [rest]
------------------------------------------------------------------------
## gcd2
Compiled GCD function.
### Discussion
See [gcd].
### Crosslinks
[gcd]
------------------------------------------------------------------------ ------------------------------------------------------------------------
## gcd ## gcd
@ -1190,7 +1186,7 @@ Greater-than-or-equal-to comparison of two numbers.
[gt] [gt]
[le] [le]
[lt] [lt]
[ne] [neq]
------------------------------------------------------------------------ ------------------------------------------------------------------------
@ -1374,7 +1370,7 @@ Greater-than comparison of two numbers.
[ge] [ge]
[le] [le]
[lt] [lt]
[ne] [neq]
------------------------------------------------------------------------ ------------------------------------------------------------------------
@ -1406,23 +1402,6 @@ See [pred](#pred).
See [sub](#sub). See [sub](#sub).
------------------------------------------------------------------------
## hypot
x y hypot
---------------------------
sqrt(sqr(x) + sqr(y))
### Discussion
This is another function that has to wait on the numeric tower.
### Crosslinks
[sqrt]
------------------------------------------------------------------------ ------------------------------------------------------------------------
## id ## id
@ -1595,7 +1574,7 @@ stack, replacing them with a Boolean value.
[ge] [ge]
[gt] [gt]
[lt] [lt]
[ne] [neq]
-------------- --------------
@ -1608,7 +1587,7 @@ See [le](#le).
## <> ## <>
See [ne](#ne). See [neq](#neq).
------------------------------------------------------------------------ ------------------------------------------------------------------------
@ -1733,7 +1712,7 @@ stack, replacing them with a Boolean value.
[ge] [ge]
[gt] [gt]
[le] [le]
[ne] [neq]
------------------------------------------------------------------------ ------------------------------------------------------------------------
@ -1886,12 +1865,12 @@ Invert the sign of a number.
------------------------------------------------------------------------ ------------------------------------------------------------------------
## ne ## neq
Not-Equal comparison of the two items on the top of the Not-Equal comparison of the two items on the top of the
stack, replacing them with a Boolean value. stack, replacing them with a Boolean value.
a b ne a b neq
------------- -------------
Boolean Boolean
(a = b) (a = b)
@ -1909,8 +1888,7 @@ stack, replacing them with a Boolean value.
## not ## not
Like [bool] but convert the item on the top of the stack to the inverse Invert the Boolean value on the top of the stack.
Boolean value.
true not true not
-------------- --------------
@ -1924,7 +1902,6 @@ Boolean value.
[bool] [bool]
------------------------------------------------------------------------ ------------------------------------------------------------------------
## nulco ## nulco
@ -1945,6 +1922,14 @@ Helper function for [or] and [and].
[or] [or]
--------------------
## null
True if the item on the top of the stack is an empty list,
false if it's a list but not empty,
and an error if it's not a list.
-------------------- --------------------
## nullary ## nullary
@ -2006,7 +1991,6 @@ Logical bit-wise OR.
### Crosslinks ### Crosslinks
[and] [and]
[xor]
------------------------------------------------------------------------ ------------------------------------------------------------------------
@ -2532,18 +2516,6 @@ See [rolldown](#rolldown).
[rolldown] [rolldown]
------------------------------------------------------------------------
## round
Round a number to a given precision in decimal digits.
### Discussion
Another one that won't make sense until the "numeric tower" is nailed
down.
------------------------------------------------------------------------ ------------------------------------------------------------------------
## rrest ## rrest
@ -2691,26 +2663,24 @@ Replace a list with its size.
3 3
--------------
## /floor
See [floordiv](#floordiv).
-------------- --------------
## / ## /
See [floordiv](#floordiv). See [div](#div).
-------------- ------------------------------------------------------------------------
## // ## small
See [floordiv](#floordiv). Return `true` if the item on the top of the stack is a list with zero or one item in it,
`false` if it is a list with more than one item in it,
and an error if it is not a list.
### Crosslinks
[null]
------------------------------------------------------------------------ ------------------------------------------------------------------------
@ -2792,20 +2762,6 @@ Square the number on the top of the stack.
------------ ------------
------------------------------------------------------------------------
## sqrt
Function Combinator
Return the square root of the number a. Negative numbers return complex
roots.
### Discussion
Another "numeric tower" hatch...
------------------------------------------------------------------------ ------------------------------------------------------------------------
## stackd ## stackd
@ -2818,6 +2774,9 @@ Grab the stack under the top item and put it onto the stack.
------------------------ ------------------------
... 1 2 [2 1 ...] 3 ... 1 2 [2 1 ...] 3
### Crosslinks
[stack]
------------------------------------------------------------------------ ------------------------------------------------------------------------
@ -2838,6 +2797,8 @@ complement to the "destructive" pair [enstacken] and [disenstacken].
[enstacken] [enstacken]
[disenstacken] [disenstacken]
[stackd]
[unstack]
------------------------------------------------------------------------ ------------------------------------------------------------------------
@ -3160,13 +3121,6 @@ another program which does the actual work. This is kind of like macros
in Lisp, or preprocessor directives in C. in Lisp, or preprocessor directives in C.
--------------
## truthy
See [bool](#bool).
------------------------------------------------------------------------ ------------------------------------------------------------------------
## tuck ## tuck
@ -3245,6 +3199,26 @@ Given a list remove duplicate items.
------------------------------------------------------------------------ ------------------------------------------------------------------------
## unstack
Take a list from the top of the stack and `concat` it to the stack.
joy? 1 2 3 [4 5 6]
1 2 3 [4 5 6]
joy? unstack
1 2 3 6 5 4
### Crosslinks
[stack]
[disenstacken]
[enstacken]
------------------------------------------------------------------------
## unquoted ## unquoted
Combinator Combinator
@ -3377,20 +3351,6 @@ See the [Recursion Combinators notebook](https://joypy.osdn.io/notebooks/Recursi
as well as as well as
[Recursion Theory and Joy](https://www.kevinalbrecht.com/code/joy-mirror/j05cmp.html) by Manfred von [Recursion Theory and Joy](https://www.kevinalbrecht.com/code/joy-mirror/j05cmp.html) by Manfred von
------------------------------------------------------------------------
## xor
Logical bit-wise eXclusive OR.
### Crosslinks
[and]
[or]
------------------------------------------------------------------------ ------------------------------------------------------------------------
## zip ## zip

View File

@ -64,7 +64,7 @@ dup swap pop clear
add sub mul div rem remainder add sub mul div rem remainder
+ - * / % + - * / %
concat concat
truthy truthy bool
inscribe inscribe
< > >= <= != <> = < > >= <= != <> =
gt lt ge le neq eq gt lt ge le neq eq

View File

@ -43,6 +43,7 @@ dupdipd dup dipd
dupdip dupd dip dupdip dupd dip
enstacken stack [clear] dip enstacken stack [clear] dip
first uncons pop first uncons pop
first_two uncons first
flatten <{} [concat] step flatten <{} [concat] step
fork [i] app2 fork [i] app2
fourth rest third fourth rest third
@ -50,7 +51,6 @@ gcd true [tuck mod dup 0 >] loop pop
genrec [[genrec] ccccons] nullary swons concat ifte genrec [[genrec] ccccons] nullary swons concat ifte
grabN <{} [cons] times grabN <{} [cons] times
grba [stack popd] dip grba [stack popd] dip
hypot [sqr] ii + sqrt
ifte [nullary] dipd swap branch ifte [nullary] dipd swap branch
ii [dip] dupdip i ii [dip] dupdip i
infra swons swaack [i] dip swaack infra swons swaack [i] dip swaack
@ -63,7 +63,7 @@ neg 0 swap -
not [true] [false] branch not [true] [false] branch
nulco [nullary] cons nulco [nullary] cons
nullary [stack] dinfrirst nullary [stack] dinfrirst
null [] swap concat bool not null _isnt_list bool not
of swap at of swap at
or nulco [nullary] dip [true] branch or nulco [nullary] dip [true] branch
over [dup] dip swap over [dup] dip swap
@ -134,9 +134,9 @@ _mape popd reverse
_map0 [_map1] dipd _map2 _map0 [_map1] dipd _map2
_map1 stackd shift _map1 stackd shift
_map2 [infrst] cons dipd roll< swons _map2 [infrst] cons dipd roll< swons
_isnt_bool not not _isnt_bool [false] [true] branch
_isnt_two_bools [_isnt_bool] ii _isnt_two_bools [_isnt_bool] ii
_\/_ [_isnt_bool] [not] branch _\/_ [_isnt_bool] [not] branch
/\ _isnt_two_bools [pop false] [] branch /\ _isnt_two_bools [pop false] [] branch
\/ _isnt_two_bools [] [pop true] branch \/ _isnt_two_bools [] [pop true] branch
xor [] [not] branch _isnt_list [] swoncat