diff --git a/docs/html/FuncRef.html b/docs/html/FuncRef.html index f417ac8..68cca1b 100644 --- a/docs/html/FuncRef.html +++ b/docs/html/FuncRef.html @@ -1,4 +1,4 @@ -
Version -10.0.0
Each function, combinator, or definition should be documented here.
Not negative.
+Version -10.0.0
Each function, combinator, or definition should be documented here.
Not negative.
n !-
----------- n < 0
false
@@ -8,14 +8,14 @@
---------- n >= 0
true
Return a Boolean value indicating if a number is greater than or equal to -zero.
... b a <{}
+zero. ... b a <{}
-----------------
... [] b a
-Tuck an empty list just under the first two items on the stack.
... a <{}
+Tuck an empty list just under the first two items on the stack.
... a <{}
----------------
... [] a
Tuck an empty list just under the first item on the stack.
Is the item on the top of the stack "truthy"?
You often want to test the truth value of an item on the stack without -consuming the item.
combinator
Build a list of values from a generator program G and a stopping
+consuming the item.
combinator
Build a list of values from a generator program G and a stopping
predicate P.
[P] [G] anamorphism
-----------------------------------------
@@ -102,8 +102,8 @@ item of the result on the stack.
-----------------------
... a
Runs any other quoted function and returns its first result while -consuming exactly two items from the stack.
Convert the item on the top of the stack to a Boolean value.
For integers 0 is false and any other number is true; for lists the
-empty list is false and all other lists are true.
combinator built-in
Use a Boolean value to select and run one of two quoted programs.
+consuming exactly two items from the stack.built-in
Convert the item on the top of the stack to a Boolean value.
For integers 0 is false and any other number is true; for lists the
+empty list is false and all other lists are true.
combinator built-in
Use a Boolean value to select and run one of two quoted programs.
false [F] [T] branch
--------------------------
F
@@ -113,7 +113,7 @@ empty list is false and all other lists are true.<
T
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].
a b c d [...] ccccons
+[ifte] adds a predicate function that is evaluated [nullary]. a b c d [...] ccccons
---------------------------
[a b c d ...]
@@ -170,7 +170,7 @@ and not all three possibilities, e.g.:
[G] [EL] dup cmp
[GE] [L] dupd cmp
Or even:
- [GL] [E] over cmpcombinator
Take a quoted program from the stack, [cons] the next item onto it, then + [GL] [E] over cmp
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
--------------------
@@ -184,7 +184,7 @@ as well as
[a b c] [d e f] concat
----------------------------
[a b c d e f]
-
combinator
This combinator works like a case statement. It expects a single quote +
combinator
This combinator works like a case statement. It expects a single quote on the stack that must contain zero or more condition quotes and a default quote. Each condition quote should contain a quoted predicate followed by the function expression to run if that predicate returns @@ -206,7 +206,7 @@ expressions, e.g.: ------------------ [a ...]
Cons is a venerable old function from Lisp. -Its inverse operation is [uncons].
combinator built-in
The dip combinator expects a quoted program on the stack and below it
+Its inverse operation is [uncons].
combinator built-in
The dip combinator expects a quoted program on the stack and below it
some item, it hoists the item into the expression and runs the program
on the rest of the stack.
... x [Q] . dip
@@ -224,22 +224,26 @@ Continuation-Passing Style. The dip combinator could "set aside" t
item and replace it after running Q but that means that there is an
"extra space" where the item resides while Q runs. One of the nice
things about CPS is that the whole state is recorded in the stack and
-pending expression (not counting modifications to the dictionary.)combinator
Like [dip] but expects two items.
+pending expression (not counting modifications to the dictionary.)combinator
Like [dip] but expects two items.
... y x [Q] . dipd
-------------------------
... . Q y x
-See [dip].
combinator
Like [dip] but expects three items. :
+ ... z y x [Q] . dipdd
-----------------------------
... . Q z y x
-See [dip].
The disenstacken function expects a list on top of the stack and makes
+
See [dip].
combinator
Like [dip] but expects four items. :
+ ... z y x w [Q] . dipddd
+-------------------------------
+ ... . Q z y x w
+See [dip].
The disenstacken function expects a list on top of the stack and makes
that the stack discarding the rest of the stack.
1 2 3 [4 5 6] disenstacken
--------------------------------
6 5 4
Note that the order of the list is not changed, it just looks that way because the stack is printed with the top on the right while lists are -printed with the top or head on the left.
x y divmod
+printed with the top or head on the left. x y divmod
------------------
q r
(x/y) (x%y)
@@ -260,7 +264,7 @@ items removed off the top.
a dup
-----------
a a
-
[dup] the second item down on the stack.
+[dup] the second item down on the stack.
a b dupd
--------------
a a b
@@ -289,34 +293,27 @@ a F a
-------------------------
[c b a ...]
This is a destructive version of [stack]. See the note under -[disenstacken] about the apparent but illusory reversal of the stack.
built-in
Compare the two items on the top of the stack for equality and replace +[disenstacken] about the apparent but illusory reversal of the stack.
built-in
Compare the two items on the top of the stack for equality and replace them with a Boolean value.
a b eq
-------------
Boolean
(a = b)
-Replace a list with its first two items.
+Replace a list with its first two items.
[a b ...] first_two
-------------------------
a b
-Given a list of lists, concatinate them.
+Given a list of lists, concatinate them.
[[1 2] [3 [4] 5] [6 7]] flatten
-------------------------------------
[1 2 3 [4] 5 6 7]
Note that only one "level" of lists is flattened. In the example above
-[4] is not unquoted.
Return the largest integer \<= x.
This function doesn't make sense (yet) to have because there are (as yet) -only integers in the system.
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)
-All the division commands need to be revisited when the "numeric tower" -for Thun gets nailed down.
combinator
Run two quoted programs in parallel and replace them with their results.
+[4] is not unquoted.combinator
Run two quoted programs in parallel and replace them with their results.
... [F] [G] fork
----------------------
... f g
@@ -325,12 +322,12 @@ for Thun gets nailed down.Take two integers from the stack and replace them with their Greatest -Common Denominator.
Euclid's Algorithm
built-in
Greater-than-or-equal-to comparison of two numbers.
+Common Denominator.Euclid's Algorithm
built-in
Greater-than-or-equal-to comparison of two numbers.
a b ge
--------------
Boolean
(a >= b)
-combinator
General Recursion Combinator.
[if] [then] [rec1] [rec2] genrec
---------------------------------------------------------------------
[if] [then] [rec1 [[if] [then] [rec1] [rec2] genrec] rec2] ifte
@@ -393,15 +390,12 @@ It's part of the [app2] definition.Accepts a quoted symbol on the top of the stack and prints its +
Accepts a quoted symbol on the top of the stack and prints its documentation.
[foo] help
----------------
Technically this is equivalent to pop, but it will only work if the
-item on the top of the stack is a quoted symbol.
x y hypot
----------------------------
- sqrt(sqr(x) + sqr(y))
-This is another function that has to wait on the numeric tower.
combinator built-in
Append a quoted expression onto the pending expression.
+item on the top of the stack is a quoted symbol.combinator built-in
Append a quoted expression onto the pending expression.
[Q] . i
-------------
. Q
@@ -433,7 +427,7 @@ top item, then again with the top item.
1 9
1 2 3 4 [+] app2
----------------------
- 1 2 5 6combinator
Accept a quoted program and a list on the stack and run the program with + 1 2 5 6
combinator
Accept a quoted program and a list on the stack and run the program with the list as its stack. Does not affect the stack (below the list.)
... x y z [a b c] [Q] infra
---------------------------------
@@ -464,7 +458,7 @@ stack, replacing them with a Boolean value.
-------------
Boolean
(a <= b)
-combinator built-in
Expect a quoted program Q and a Boolean value on the stack. If the value is false
+
combinator built-in
Expect a quoted program Q and a Boolean value on the stack. If the value is false
discard the quoted program, otherwise run a copy of Q and loop again.
false [Q] loop
--------------------
@@ -493,7 +487,7 @@ stack, replacing them with a Boolean value.
-------------
Boolean
(a < b)
-Given an initial state value and a quoted generator function build a +
Given an initial state value and a quoted generator function build a generator quote.
state [generator function] make_generator
-----------------------------------------------
@@ -534,18 +528,17 @@ parallelism combinator due to the "pure" nature of the language. a b mul
-------------
(a×b)
-Not-Equal comparison of the two items on the top of the -stack, replacing them with a Boolean value.
- a b ne
--------------
- Boolean
- (a = b)
-Like [bool] but convert the item on the top of the stack to the inverse -Boolean value.
+built-in
Not-Equal comparison of the two items on the top of the +stack, replacing them with a Boolean value.
+ a b neq
+-------------
+ Boolean
+ (a = b)
+Invert the Boolean value on the top of the stack.
true not
--------------
false
@@ -553,11 +546,13 @@ Boolean value.
false not
---------------
true
-Take the item on the top of the stack and [cons] it onto [nullary].
Take the item on the top of the stack and [cons] it onto [nullary].
[F] nulco
-------------------
[[F] nullary]
-Helper function for [or] and [and].
combinator
Run a quoted program without using any stack values and leave the first +
Helper function for [or] and [and].
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.
combinator
Run a quoted program without using any stack values and leave the first item of the result on the stack.
... [P] nullary
---------------------
@@ -577,7 +572,7 @@ program.)[dup] the second item on the stack over the first.
a b over
--------------
a b a
@@ -606,7 +601,7 @@ the underlying [map] function is so implemented, of course.)[pop] the second item down on the stack.
+[pop] the second item down on the stack.
a b popd
--------------
b
@@ -706,7 +701,7 @@ or the item isn't in the list then the list is unchanged.
See the "Remove Function" notebook.
Reverse the list on the top of the stack.
+Reverse the list on the top of the stack.
[1 2 3] reverse
---------------------
@@ -717,8 +712,7 @@ or the item isn't in the list then the list is unchanged.
Round a number to a given precision in decimal digits.
Another one that won't make sense until the "numeric tower" is nailed -down.
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.
Given a list return it sorted.
[4 2 5 7 1] sort
----------------------
@@ -782,19 +778,17 @@ list.
n sqr
------------
n²
-
Function Combinator
-Return the square root of the number a. Negative numbers return complex -roots.
Another "numeric tower" hatch...
built-in
Put the stack onto the stack.
... c b a stack
---------------------------
... c b a [a b c ...]
This function forms a pair with [unstack], and together they form the -complement to the "destructive" pair [enstacken] and [disenstacken].
Grab the stack under the top item and put it onto the stack.
+complement to the "destructive" pair [enstacken] and [disenstacken].Grab the stack under the top item and put it onto the stack.
... 1 2 3 stackd
------------------------
... 1 2 [2 1 ...] 3
-combinator
Run a quoted program on each item in a sequence.
... [] [Q] step
---------------------
...
@@ -839,15 +833,15 @@ with the list, and put the old stack onto it.
--------------------------
6 5 4 [3 2 1]
This function works as a kind of "context switch". It's used in the -definition of [infra].
Swap the second and third items on the stack.
a b c swapd
-----------------
b a c
-Like [cons] but [swap] the item and list.
+Like [cons] but [swap] the item and list.
[...] a swons
-------------------
[a ...]
@@ -896,7 +890,7 @@ program n times.
This is a common pattern in Joy. You accept some parameters from the
stack which typically include qouted programs and use them to build
another program which does the actual work. This is kind of like macros
-in Lisp, or preprocessor directives in C.[dup] the item on the top of the stack under the second item on the +in Lisp, or preprocessor directives in C.
[dup] the item on the top of the stack under the second item on the stack.
a b tuck
--------------
@@ -913,7 +907,7 @@ the list. You cannot uncons an item from an empty list.
[a ...] uncons
--------------------
a [...]
-
This is the inverse of [cons].
Given a list remove duplicate items.
Given a list remove duplicate items.
combinator
Unquote (using [i]) the list that is second on the stack.
@@ -921,7 +915,15 @@ the list. You cannotuncons an item from an empty list.
1 2 [3 4] 5 unquoted
--------------------------
1 2 3 4 5
-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
+True if the form on TOS is void otherwise False.
A form is any Joy expression composed solely of lists. @@ -942,7 +944,7 @@ the stack.
The simplest recursive pattern. See the Recursion Combinators notebook. as well as -Recursion Theory and Joy by Manfred von
Replace the two lists on the top of the stack with a list of the pairs +Recursion Theory and Joy by Manfred von
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.
[1 2 3] [4 5 6] zip
diff --git a/docs/reference/Function-Reference.md b/docs/reference/Function-Reference.md
index 196fbfb..b5a3714 100644
--- a/docs/reference/Function-Reference.md
+++ b/docs/reference/Function-Reference.md
@@ -6,6 +6,30 @@ Version -10.0.0
Each function, combinator, or definition should be documented here.
+------------------------------------------------------------------------
+
+## /\
+
+Binary Boolean *and*.
+
+### Crosslinks
+
+[bool]
+[not]
+[\/]
+
+------------------------------------------------------------------------
+
+## \/
+
+Binary Boolean *or*.
+
+### Crosslinks
+
+[bool]
+[not]
+[/\]
+
------------------------------------------------------------------------
## abs
@@ -390,13 +414,6 @@ the other way around.
[select]
---------------
-
-## ^
-
-See [xor](#xor).
-
-
------------------------------------------------------------------------
## 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
Combinator
Like [dip] but expects three items. :
- ... z y x [Q] . dip
+ ... z y x [Q] . dipdd
-----------------------------
... . Q z y x
### Discussion
@@ -665,11 +707,11 @@ See [dip].
[dip]
[dipd]
+[dipddd]
[dupdip]
[dupdipd]
[infra]
-
------------------------------------------------------------------------
## dipd
@@ -690,6 +732,7 @@ See [dip].
[dip]
[dipdd]
+[dipddd]
[dupdip]
[dupdipd]
[infra]
@@ -755,13 +798,13 @@ printed with the top or head on the left.
[enstacken]
[stack]
+[unstack]
-
---------------
+--------------------------------------------
## div
-See [floordiv](#floordiv).
+Divide.
------------------------------------------------------------------------
@@ -933,6 +976,7 @@ This is a destructive version of [stack]. See the note under
[stack]
[disenstacken]
+[unstack]
------------------------------------------------------------------------
@@ -954,7 +998,7 @@ them with a Boolean value.
[gt]
[le]
[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]
-------------------------------------------------------------------------
-
-## 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
@@ -1145,21 +1156,6 @@ Replace a list with its fourth item.
[rest]
-------------------------------------------------------------------------
-
-## gcd2
-
-Compiled GCD function.
-
-### Discussion
-
-See [gcd].
-
-### Crosslinks
-
-[gcd]
-
-
------------------------------------------------------------------------
## gcd
@@ -1190,7 +1186,7 @@ Greater-than-or-equal-to comparison of two numbers.
[gt]
[le]
[lt]
-[ne]
+[neq]
------------------------------------------------------------------------
@@ -1374,7 +1370,7 @@ Greater-than comparison of two numbers.
[ge]
[le]
[lt]
-[ne]
+[neq]
------------------------------------------------------------------------
@@ -1406,23 +1402,6 @@ See [pred](#pred).
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
@@ -1595,7 +1574,7 @@ stack, replacing them with a Boolean value.
[ge]
[gt]
[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]
[gt]
[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
stack, replacing them with a Boolean value.
- a b ne
+ a b neq
-------------
Boolean
(a = b)
@@ -1909,8 +1888,7 @@ stack, replacing them with a Boolean value.
## not
-Like [bool] but convert the item on the top of the stack to the inverse
-Boolean value.
+Invert the Boolean value on the top of the stack.
true not
--------------
@@ -1924,7 +1902,6 @@ Boolean value.
[bool]
-
------------------------------------------------------------------------
## nulco
@@ -1945,6 +1922,14 @@ Helper function for [or] and [and].
[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
@@ -2006,7 +1991,6 @@ Logical bit-wise OR.
### Crosslinks
[and]
-[xor]
------------------------------------------------------------------------
@@ -2532,18 +2516,6 @@ See [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
@@ -2691,26 +2663,24 @@ Replace a list with its size.
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.
------------
n²
-------------------------------------------------------------------------
-
-## sqrt
-
-Function Combinator
-
-Return the square root of the number a. Negative numbers return complex
-roots.
-
-### Discussion
-
-Another "numeric tower" hatch...
-
-
------------------------------------------------------------------------
## stackd
@@ -2818,6 +2774,9 @@ Grab the stack under the top item and put it onto the stack.
------------------------
... 1 2 [2 1 ...] 3
+### Crosslinks
+
+[stack]
------------------------------------------------------------------------
@@ -2838,6 +2797,8 @@ complement to the "destructive" pair [enstacken] and [disenstacken].
[enstacken]
[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.
---------------
-
-## truthy
-
-See [bool](#bool).
-
-
------------------------------------------------------------------------
## 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
Combinator
@@ -3377,20 +3351,6 @@ See the [Recursion Combinators notebook](https://joypy.osdn.io/notebooks/Recursi
as well as
[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
diff --git a/docs/reference/to_html.py b/docs/reference/to_html.py
index 8738e22..ce54218 100644
--- a/docs/reference/to_html.py
+++ b/docs/reference/to_html.py
@@ -64,7 +64,7 @@ dup swap pop clear
add sub mul div rem remainder
+ - * / %
concat
-truthy
+truthy bool
inscribe
< > >= <= != <> =
gt lt ge le neq eq
diff --git a/implementations/defs.txt b/implementations/defs.txt
index 045f14f..c36137b 100644
--- a/implementations/defs.txt
+++ b/implementations/defs.txt
@@ -43,6 +43,7 @@ dupdipd dup dipd
dupdip dupd dip
enstacken stack [clear] dip
first uncons pop
+first_two uncons first
flatten <{} [concat] step
fork [i] app2
fourth rest third
@@ -50,7 +51,6 @@ gcd true [tuck mod dup 0 >] loop pop
genrec [[genrec] ccccons] nullary swons concat ifte
grabN <{} [cons] times
grba [stack popd] dip
-hypot [sqr] ii + sqrt
ifte [nullary] dipd swap branch
ii [dip] dupdip i
infra swons swaack [i] dip swaack
@@ -63,7 +63,7 @@ neg 0 swap -
not [true] [false] branch
nulco [nullary] cons
nullary [stack] dinfrirst
-null [] swap concat bool not
+null _isnt_list bool not
of swap at
or nulco [nullary] dip [true] branch
over [dup] dip swap
@@ -134,9 +134,9 @@ _mape popd reverse
_map0 [_map1] dipd _map2
_map1 stackd shift
_map2 [infrst] cons dipd roll< swons
-_isnt_bool not not
+_isnt_bool [false] [true] branch
_isnt_two_bools [_isnt_bool] ii
_\/_ [_isnt_bool] [not] branch
/\ _isnt_two_bools [pop false] [] branch
\/ _isnt_two_bools [] [pop true] branch
-xor [] [not] branch
+_isnt_list [] swoncat