diff --git a/docs/reference/mkref/FuncRef.html b/docs/reference/mkref/FuncRef.html index 7a4565d..879fc2e 100644 --- a/docs/reference/mkref/FuncRef.html +++ b/docs/reference/mkref/FuncRef.html @@ -2276,256 +2276,226 @@ a F a
Basis Function Combinator
-[i] genrec
-Gentzen diagram.
+Combinator
+A specialization of the genrec combinator.
if not basis.
-if not basis.
-if basis
++ +
Lorem ipsum.
+Some recursive functions do not need to store additional data or pending actions per-call. These are called “tail recursive” functions. In Joy, they appear as genrec definitions that have i for the second half of their recursive branch.
+See the Recursion Combinators notebook.
Lorem ipsum.
+Basis Function Combinator
-Expects an integer and a quote on the stack and returns the quote with just the top n items in reverse order (because that's easier and you can use reverse if needed.) :
-[a b c d] 2 take
+Function
+Expects an integer n and a list on the stack and replace them with a list with just the top n items in reverse order.
+ [a b c d] 2 take
----------------------
- [b a]
-Gentzen diagram.
+ [b a]
if not basis.
-if not basis.
-if basis
-Lorem ipsum.
-Lorem ipsum.
++ +
(Combinator)
+Combinator
Run a quoted program using exactly three stack values and leave the first item of the result on the stack.
- ... z y x [P] unary
+ ... z y x [P] ternary
-------------------------
- ... A
+ ... 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.
+Function
+ [a b c ...] third
+-----------------------
+ c
if not basis.
-if not basis.
-if basis
-Lorem ipsum.
-Lorem ipsum.
++ ++
Basis Function Combinator
-times == [-- dip] cons [swap] infra [0 >] swap while pop :
-... n [Q] . times
---------------------- w/ n <= 0
- ... .
+Combinator
+Expect a quoted program and an integer n on the stack and do the program n times.
+ ... n [Q] . times
+----------------------- w/ n <= 0
+ ... .
-
-... 1 [Q] . times
+ ... 1 [Q] . times
-----------------------
- ... . Q
+ ... . Q
-
-... n [Q] . times
+ ... n [Q] . times
------------------------------------- w/ n > 1
- ... . Q (n - 1) [Q] times
-Gentzen diagram.
+ ... . Q (n-1) [Q] times
if not basis.
-if not basis.
-if basis
-Lorem ipsum.
-Lorem ipsum.
+++[-- dip] cons [swap] infra [0 >] swap while pop :
+
This works by building a little while program and running it:
+ 1 3 [++] • [-- dip] cons [swap] infra [0 >] swap while pop
+ 1 3 [++] [-- dip] • cons [swap] infra [0 >] swap while pop
+ 1 3 [[++] -- dip] • [swap] infra [0 >] swap while pop
+ 1 3 [[++] -- dip] [swap] • infra [0 >] swap while pop
+ dip -- [++] • swap [3 1] swaack [0 >] swap while pop
+ dip [++] -- • [3 1] swaack [0 >] swap while pop
+ dip [++] -- [3 1] • swaack [0 >] swap while pop
+ 1 3 [-- [++] dip] • [0 >] swap while pop
+ 1 3 [-- [++] dip] [0 >] • swap while pop
+ 1 3 [0 >] [-- [++] dip] • while pop
+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.
See bool.
Basis Function Combinator
-(a2 a1 -- a1 a2 a1)
-Gentzen diagram.
+Function
+dup the item on the top of the stack under the second item on the stack.
+ a b tuck
+--------------
+ b a b
if not basis.
-if not basis.
-if basis
-Lorem ipsum.
-Lorem ipsum.
++ ++
(Combinator)
Run a quoted program using exactly one stack value and leave the first item of the result on the stack.
... x [P] unary
---------------------
- ... A
+ ... a
nullary popd
-+ ++
Runs any other quoted function and returns its first result while consuming exactly one item from the stack.
-(Basis Function)
+Basis Function
Removes an item from a list and leaves it on the stack under the rest of the list. You cannot uncons an item from an empty list.
[A ...] uncons
+ [a ...] uncons
--------------------
- A [...]
-Source
-func(uncons, Si, So) :- func(cons, So, Si).
-Discussion
-This is the inverse of cons.
-Crosslinks
+ a [...]
+This is the inverse of cons.
+Basis Function Combinator
+Function
Given a list remove duplicate items.
-Gentzen diagram.
-if not basis.
-if not basis.
-if basis
-Lorem ipsum.
-Lorem ipsum.
Basis Function Combinator
-(a1 -- [a1 ])
-Gentzen diagram.
-if not basis.
-if not basis.
-if basis
-Lorem ipsum.
-Lorem ipsum.
+Function
+ a unit
+------------
+ [a]
++[] cons
+
Basis Function Combinator
-[i] dip
-Gentzen diagram.
-if not basis.
-if not basis.
-if basis
-Lorem ipsum.
-Lorem ipsum.
+Combinator
+Unquote (using i) the list that is second on the stack.
+ 1 2 [3 4] 5 unquoted
+--------------------------
+ 1 2 3 4 5
++ ++
Basis Function Combinator
-([a1 ...1] -- [...1] a1)
-Gentzen diagram.
-if not basis.
-if not basis.
-if basis
-Lorem ipsum.
-Lorem ipsum.
+Function
+ [a ...] unswons
+---------------------
+ [...] a
++ +
Basis 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.
Basis Function Combinator
Print warranty information.
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
-Lorem ipsum.
-Lorem ipsum.
Basis Function Combinator
swap nulco dupdipd concat loop
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
-Lorem ipsum.
-Lorem ipsum.
Basis Function Combinator
Print all the words in alphabetical order.
Gentzen diagram.
-if not basis.
-if not basis.
-if basis
-Lorem ipsum.
-Lorem ipsum.
[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.
Basis 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.