diff --git a/docs/0._This_Implementation_of_Joy_in_Python.html b/docs/0._This_Implementation_of_Joy_in_Python.html index 67706aa..decee02 100644 --- a/docs/0._This_Implementation_of_Joy_in_Python.html +++ b/docs/0._This_Implementation_of_Joy_in_Python.html @@ -13133,17 +13133,84 @@ joy?
import inspect
+import inspect
import joy.utils.stack
-print inspect.getdoc(joy.utils.stack)
+print(inspect.getdoc(joy.utils.stack))
When talking about Joy we use the terms "stack", "quote", "sequence", +"list", and others to mean the same thing: a simple linear datatype that +permits certain operations such as iterating and pushing and popping +values from (at least) one end. + +There is no "Stack" Python class, instead we use the `cons list`_, a +venerable two-tuple recursive sequence datastructure, where the +empty tuple ``()`` is the empty stack and ``(head, rest)`` gives the +recursive form of a stack with one or more items on it:: + + stack := () | (item, stack) + +Putting some numbers onto a stack:: + + () + (1, ()) + (2, (1, ())) + (3, (2, (1, ()))) + ... + +Python has very nice "tuple packing and unpacking" in its syntax which +means we can directly "unpack" the expected arguments to a Joy function. + +For example:: + + def dup((head, tail)): + return head, (head, tail) + +We replace the argument "stack" by the expected structure of the stack, +in this case "(head, tail)", and Python takes care of unpacking the +incoming tuple and assigning values to the names. (Note that Python +syntax doesn't require parentheses around tuples used in expressions +where they would be redundant.) + +Unfortunately, the Sphinx documentation generator, which is used to generate this +web page, doesn't handle tuples in the function parameters. And in Python 3, this +syntax was removed entirely. Instead you would have to write:: + + def dup(stack): + head, tail = stack + return head, (head, tail) + + +We have two very simple functions, one to build up a stack from a Python +iterable and another to iterate through a stack and yield its items +one-by-one in order. There are also two functions to generate string representations +of stacks. They only differ in that one prints the terms in stack from left-to-right while the other prints from right-to-left. In both functions *internal stacks* are +printed left-to-right. These functions are written to support :doc:`../pretty`. + +.. _cons list: https://en.wikipedia.org/wiki/Cons#Lists ++
joy.utils.stack.list_to_stack([1, 2, 3])
+joy.utils.stack.list_to_stack([1, 2, 3])
(1, (2, (3, ())))+
list(joy.utils.stack.iter_stack((1, (2, (3, ())))))
+list(joy.utils.stack.iter_stack((1, (2, (3, ())))))
[1, 2, 3]+
stack = ()
+stack = ()
for n in [1, 2, 3]:
stack = n, stack
-print stack
-print list(joy.utils.stack.iter_stack(stack))
+print(stack)
+print(list(joy.utils.stack.iter_stack(stack)))
(3, (2, (1, ()))) +[3, 2, 1] ++
import joy.joy
+import joy.joy
-print inspect.getsource(joy.joy.joy)
+print(inspect.getsource(joy.joy.joy))
def joy(stack, expression, dictionary, viewer=None): + '''Evaluate a Joy expression on a stack. + + This function iterates through a sequence of terms which are either + literals (strings, numbers, sequences of terms) or function symbols. + Literals are put onto the stack and functions are looked up in the + disctionary and executed. + + The viewer is a function that is called with the stack and expression + on every iteration, its return value is ignored. + + :param stack stack: The stack. + :param stack expression: The expression to evaluate. + :param dict dictionary: A ``dict`` mapping names to Joy functions. + :param function viewer: Optional viewer function. + :rtype: (stack, (), dictionary) + + ''' + while expression: + + if viewer: viewer(stack, expression) + + term, expression = expression + if isinstance(term, Symbol): + term = dictionary[term] + stack, expression, dictionary = term(stack, expression, dictionary) + else: + stack = term, stack + + if viewer: viewer(stack, expression) + return stack, expression, dictionary + ++
import joy.parser
+import joy.parser
-print inspect.getdoc(joy.parser)
+print(inspect.getdoc(joy.parser))
print inspect.getsource(joy.parser._parse)
+print(inspect.getsource(joy.parser._parse))
joy.parser.text_to_expression('1 2 3 4 5') # A simple sequence.
+joy.parser.text_to_expression('1 2 3 4 5') # A simple sequence.
joy.parser.text_to_expression('[1 2 3] 4 5') # Three items, the first is a list with three items
+joy.parser.text_to_expression('[1 2 3] 4 5') # Three items, the first is a list with three items
joy.parser.text_to_expression('1 23 ["four" [-5.0] cons] 8888') # A mixed bag. cons is
+joy.parser.text_to_expression('1 23 ["four" [-5.0] cons] 8888') # A mixed bag. cons is
# a Symbol, no lookup at
# parse-time. Haiku docs.
@@ -13492,7 +13667,7 @@ around square brackets.
In [11]:
-joy.parser.text_to_expression('[][][][][]') # Five empty lists.
+joy.parser.text_to_expression('[][][][][]') # Five empty lists.
@@ -13525,7 +13700,7 @@ around square brackets.
In [12]:
-joy.parser.text_to_expression('[[[[[]]]]]') # Five nested lists.
+joy.parser.text_to_expression('[[[[[]]]]]') # Five nested lists.
@@ -13566,9 +13741,9 @@ around square brackets.
In [13]:
-import joy.library
+import joy.library
-print ' '.join(sorted(joy.library.initialize()))
+print(' '.join(sorted(joy.library.initialize())))
@@ -13585,7 +13760,7 @@ around square brackets.
-!= % & * *fraction *fraction0 + ++ - -- / // /floor < << <= <> = > >= >> ? ^ _Tree_add_Ee _Tree_delete_R0 _Tree_delete_clear_stuff _Tree_get_E abs add anamorphism and app1 app2 app3 at average b binary bool branch ccons choice clear cleave cmp codireco concat cond cons dinfrirst dip dipd dipdd disenstacken divmod down_to_zero drop dup dupd dupdd dupdip dupdipd enstacken eq first first_two flatten floor floordiv fork fourth gcd ge genrec getitem gt help i id ifte ii infer infra inscribe le least_fraction loop lshift lt make_generator map max min mod modulus mul ne neg not nullary of or over pam parse pick pm pop popd popdd popop popopd popopdd pow pred primrec product quoted range range_to_zero rem remainder remove rest reverse roll< roll> rolldown rollup round rrest rshift run second select sharing shunt size sort sqr sqrt stack step step_zero stuncons stununcons sub succ sum swaack swap swoncat swons take ternary third times truediv truthy tuck unary uncons unique unit unquoted unstack unswons void warranty while words x xor zip •
+!= % & * *fraction *fraction0 + ++ - -- / // /floor < << <= <> = > >= >> ? ^ _Tree_add_Ee _Tree_delete_R0 _Tree_delete_clear_stuff _Tree_get_E abs add anamorphism and app1 app2 app3 at average b binary bool branch ccons choice clear cleave cmp codireco concat cond cons dinfrirst dip dipd dipdd disenstacken div divmod down_to_zero drop dup dupd dupdd dupdip dupdipd enstacken eq first first_two flatten floor floordiv fork fourth gcd ge genrec getitem gt help i id ifte ii infra inscribe le least_fraction loop lshift lt make_generator map max min mod modulus mul ne neg not nullary of or over pam parse pick pm pop popd popdd popop popopd popopdd pow pred primrec product quoted range range_to_zero rem remainder remove rest reverse roll< roll> rolldown rollup round rrest rshift run second select sharing shunt size sort sqr sqrt stack step step_zero stuncons stununcons sub succ sum swaack swap swoncat swons tailrec take ternary third times truediv truthy tuck unary uncons unique unit unquoted unstack unswons void warranty while words x xor zip •
@@ -13607,7 +13782,7 @@ around square brackets.
In [14]:
-print inspect.getsource(joy.library.dip)
+print(inspect.getsource(joy.library.dip))
@@ -13625,7 +13800,6 @@ around square brackets.
@inscribe
-@combinator_effect(_COMB_NUMS(), a1, s1)
@FunctionWrapper
def dip(stack, expression, dictionary):
'''
@@ -13634,9 +13808,9 @@ def dip(stack, expression, dictionary):
on the rest of the stack.
::
- ... x [Q] dip
+ ... x [Q] dip
-------------------
- ... Q x
+ ... Q x
'''
(quote, (x, stack)) = stack
@@ -13664,7 +13838,7 @@ def dip(stack, expression, dictionary):
In [15]:
-print joy.library.definitions
+print(joy.library.definitions)
@@ -13681,43 +13855,44 @@ def dip(stack, expression, dictionary):
-? == dup truthy
-*fraction == [uncons] dip uncons [swap] dip concat [*] infra [*] dip cons
-*fraction0 == concat [[swap] dip * [*] dip] infra
-anamorphism == [pop []] swap [dip swons] genrec
-average == [sum 1.0 *] [size] cleave /
-binary == nullary [popop] dip
-cleave == fork [popd] dip
-codireco == cons dip rest cons
-dinfrirst == dip infra first
-unstack == ? [uncons ?] loop pop
-down_to_zero == [0 >] [dup --] while
-dupdipd == dup dipd
-enstacken == stack [clear] dip
-flatten == [] swap [concat] step
-fork == [i] app2
-gcd == 1 [tuck modulus dup 0 >] loop pop
-ifte == [nullary not] dipd branch
-ii == [dip] dupdip i
-least_fraction == dup [gcd] infra [div] concat map
-make_generator == [codireco] ccons
-nullary == [stack] dinfrirst
-of == swap at
-pam == [i] map
-primrec == [i] genrec
-product == 1 swap [*] step
-quoted == [unit] dip
-range == [0 <=] [1 - dup] anamorphism
-range_to_zero == unit [down_to_zero] infra
-run == [] swap infra
-size == 0 swap [pop ++] step
-sqr == dup mul
-step_zero == 0 roll> step
-swoncat == swap concat
-ternary == unary [popop] dip
-unary == nullary popd
-unquoted == [i] dip
-while == swap [nullary] cons dup dipd concat loop
+? dup truthy
+*fraction [uncons] dip uncons [swap] dip concat [*] infra [*] dip cons
+*fraction0 concat [[swap] dip * [*] dip] infra
+anamorphism [pop []] swap [dip swons] genrec
+average [sum 1.0 *] [size] cleave /
+binary nullary [popop] dip
+cleave fork [popd] dip
+codireco cons dip rest cons
+dinfrirst dip infra first
+unstack ? [uncons ?] loop pop
+down_to_zero [0 >] [dup --] while
+dupdipd dup dipd
+enstacken stack [clear] dip
+flatten [] swap [concat] step
+fork [i] app2
+gcd 1 [tuck modulus dup 0 >] loop pop
+ifte [nullary not] dipd branch
+ii [dip] dupdip i
+least_fraction dup [gcd] infra [div] concat map
+make_generator [codireco] ccons
+nullary [stack] dinfrirst
+of swap at
+pam [i] map
+tailrec [i] genrec
+product 1 swap [*] step
+quoted [unit] dip
+range [0 <=] [1 - dup] anamorphism
+range_to_zero unit [down_to_zero] infra
+run [] swap infra
+size 0 swap [pop ++] step
+sqr dup mul
+step_zero 0 roll> step
+swoncat swap concat
+tailrec [i] genrec
+ternary unary [popop] dip
+unary nullary popd
+unquoted [i] dip
+while swap [nullary] cons dup dipd concat loop
@@ -13746,7 +13921,7 @@ while == swap [nullary] cons dup dipd concat loop
In [ ]:
-
+
diff --git a/docs/0._This_Implementation_of_Joy_in_Python.ipynb b/docs/0._This_Implementation_of_Joy_in_Python.ipynb
index 2313783..0a4b784 100644
--- a/docs/0._This_Implementation_of_Joy_in_Python.ipynb
+++ b/docs/0._This_Implementation_of_Joy_in_Python.ipynb
@@ -549,9 +549,9 @@
"\ton the rest of the stack.\n",
"\t::\n",
"\n",
- "\t\t\t ... x [Q] dip\n",
+ "\t\t ... x [Q] dip\n",
"\t\t-------------------\n",
- "\t\t\t\t ... Q x\n",
+ "\t\t ... Q x\n",
"\n",
"\t'''\n",
"\t(quote, (x, stack)) = stack\n",
diff --git a/docs/0._This_Implementation_of_Joy_in_Python.md b/docs/0._This_Implementation_of_Joy_in_Python.md
index 8b92cb9..ff42b83 100644
--- a/docs/0._This_Implementation_of_Joy_in_Python.md
+++ b/docs/0._This_Implementation_of_Joy_in_Python.md
@@ -48,9 +48,61 @@ import inspect
import joy.utils.stack
-print inspect.getdoc(joy.utils.stack)
+print(inspect.getdoc(joy.utils.stack))
```
+ When talking about Joy we use the terms "stack", "quote", "sequence",
+ "list", and others to mean the same thing: a simple linear datatype that
+ permits certain operations such as iterating and pushing and popping
+ values from (at least) one end.
+
+ There is no "Stack" Python class, instead we use the `cons list`_, a
+ venerable two-tuple recursive sequence datastructure, where the
+ empty tuple ``()`` is the empty stack and ``(head, rest)`` gives the
+ recursive form of a stack with one or more items on it::
+
+ stack := () | (item, stack)
+
+ Putting some numbers onto a stack::
+
+ ()
+ (1, ())
+ (2, (1, ()))
+ (3, (2, (1, ())))
+ ...
+
+ Python has very nice "tuple packing and unpacking" in its syntax which
+ means we can directly "unpack" the expected arguments to a Joy function.
+
+ For example::
+
+ def dup((head, tail)):
+ return head, (head, tail)
+
+ We replace the argument "stack" by the expected structure of the stack,
+ in this case "(head, tail)", and Python takes care of unpacking the
+ incoming tuple and assigning values to the names. (Note that Python
+ syntax doesn't require parentheses around tuples used in expressions
+ where they would be redundant.)
+
+ Unfortunately, the Sphinx documentation generator, which is used to generate this
+ web page, doesn't handle tuples in the function parameters. And in Python 3, this
+ syntax was removed entirely. Instead you would have to write::
+
+ def dup(stack):
+ head, tail = stack
+ return head, (head, tail)
+
+
+ We have two very simple functions, one to build up a stack from a Python
+ iterable and another to iterate through a stack and yield its items
+ one-by-one in order. There are also two functions to generate string representations
+ of stacks. They only differ in that one prints the terms in stack from left-to-right while the other prints from right-to-left. In both functions *internal stacks* are
+ printed left-to-right. These functions are written to support :doc:`../pretty`.
+
+ .. _cons list: https://en.wikipedia.org/wiki/Cons#Lists
+
+
### The utility functions maintain order.
The 0th item in the list will be on the top of the stack and *vise versa*.
@@ -60,10 +112,24 @@ joy.utils.stack.list_to_stack([1, 2, 3])
```
+
+
+ (1, (2, (3, ())))
+
+
+
+
```python
list(joy.utils.stack.iter_stack((1, (2, (3, ())))))
```
+
+
+
+ [1, 2, 3]
+
+
+
This requires reversing the sequence (or iterating backwards) otherwise:
@@ -73,10 +139,14 @@ stack = ()
for n in [1, 2, 3]:
stack = n, stack
-print stack
-print list(joy.utils.stack.iter_stack(stack))
+print(stack)
+print(list(joy.utils.stack.iter_stack(stack)))
```
+ (3, (2, (1, ())))
+ [3, 2, 1]
+
+
### Purely Functional Datastructures.
Because Joy lists are made out of Python tuples they are immutable, so all Joy datastructures are *[purely functional](https://en.wikipedia.org/wiki/Purely_functional_data_structure)*.
@@ -90,9 +160,43 @@ Each function is passed the stack, expression, and dictionary and returns them.
```python
import joy.joy
-print inspect.getsource(joy.joy.joy)
+print(inspect.getsource(joy.joy.joy))
```
+ def joy(stack, expression, dictionary, viewer=None):
+ '''Evaluate a Joy expression on a stack.
+
+ This function iterates through a sequence of terms which are either
+ literals (strings, numbers, sequences of terms) or function symbols.
+ Literals are put onto the stack and functions are looked up in the
+ disctionary and executed.
+
+ The viewer is a function that is called with the stack and expression
+ on every iteration, its return value is ignored.
+
+ :param stack stack: The stack.
+ :param stack expression: The expression to evaluate.
+ :param dict dictionary: A ``dict`` mapping names to Joy functions.
+ :param function viewer: Optional viewer function.
+ :rtype: (stack, (), dictionary)
+
+ '''
+ while expression:
+
+ if viewer: viewer(stack, expression)
+
+ term, expression = expression
+ if isinstance(term, Symbol):
+ term = dictionary[term]
+ stack, expression, dictionary = term(stack, expression, dictionary)
+ else:
+ stack = term, stack
+
+ if viewer: viewer(stack, expression)
+ return stack, expression, dictionary
+
+
+
### View function
The `joy()` function accepts a "viewer" function which it calls on each iteration passing the current stack and expression just before evaluation. This can be used for tracing, breakpoints, retrying after exceptions, or interrupting an evaluation and saving to disk or sending over the network to resume later. The stack and expression together contain all the state of the computation at each step.
@@ -109,7 +213,7 @@ One day I thought, What happens if you rewrite Joy to use [CSP](https://en.wikip
```python
import joy.parser
-print inspect.getdoc(joy.parser)
+print(inspect.getdoc(joy.parser))
```
This module exports a single function for converting text to a joy
@@ -134,7 +238,7 @@ The parser is extremely simple, the undocumented `re.Scanner` class does most of
```python
-print inspect.getsource(joy.parser._parse)
+print(inspect.getsource(joy.parser._parse))
```
def _parse(tokens):
@@ -233,21 +337,20 @@ The Joy library of functions (aka commands, or "words" after Forth usage) encaps
```python
import joy.library
-print ' '.join(sorted(joy.library.initialize()))
+print(' '.join(sorted(joy.library.initialize())))
```
- != % & * *fraction *fraction0 + ++ - -- / // /floor < << <= <> = > >= >> ? ^ _Tree_add_Ee _Tree_delete_R0 _Tree_delete_clear_stuff _Tree_get_E abs add anamorphism and app1 app2 app3 at average b binary bool branch ccons choice clear cleave cmp codireco concat cond cons dinfrirst dip dipd dipdd disenstacken divmod down_to_zero drop dup dupd dupdd dupdip dupdipd enstacken eq first first_two flatten floor floordiv fork fourth gcd ge genrec getitem gt help i id ifte ii infer infra inscribe le least_fraction loop lshift lt make_generator map max min mod modulus mul ne neg not nullary of or over pam parse pick pm pop popd popdd popop popopd popopdd pow pred primrec product quoted range range_to_zero rem remainder remove rest reverse roll< roll> rolldown rollup round rrest rshift run second select sharing shunt size sort sqr sqrt stack step step_zero stuncons stununcons sub succ sum swaack swap swoncat swons take ternary third times truediv truthy tuck unary uncons unique unit unquoted unstack unswons void warranty while words x xor zip •
+ != % & * *fraction *fraction0 + ++ - -- / // /floor < << <= <> = > >= >> ? ^ _Tree_add_Ee _Tree_delete_R0 _Tree_delete_clear_stuff _Tree_get_E abs add anamorphism and app1 app2 app3 at average b binary bool branch ccons choice clear cleave cmp codireco concat cond cons dinfrirst dip dipd dipdd disenstacken div divmod down_to_zero drop dup dupd dupdd dupdip dupdipd enstacken eq first first_two flatten floor floordiv fork fourth gcd ge genrec getitem gt help i id ifte ii infra inscribe le least_fraction loop lshift lt make_generator map max min mod modulus mul ne neg not nullary of or over pam parse pick pm pop popd popdd popop popopd popopdd pow pred primrec product quoted range range_to_zero rem remainder remove rest reverse roll< roll> rolldown rollup round rrest rshift run second select sharing shunt size sort sqr sqrt stack step step_zero stuncons stununcons sub succ sum swaack swap swoncat swons tailrec take ternary third times truediv truthy tuck unary uncons unique unit unquoted unstack unswons void warranty while words x xor zip •
Many of the functions are defined in Python, like `dip`:
```python
-print inspect.getsource(joy.library.dip)
+print(inspect.getsource(joy.library.dip))
```
@inscribe
- @combinator_effect(_COMB_NUMS(), a1, s1)
@FunctionWrapper
def dip(stack, expression, dictionary):
'''
@@ -256,9 +359,9 @@ print inspect.getsource(joy.library.dip)
on the rest of the stack.
::
- ... x [Q] dip
+ ... x [Q] dip
-------------------
- ... Q x
+ ... Q x
'''
(quote, (x, stack)) = stack
@@ -271,46 +374,47 @@ Some functions are defined in equations in terms of other functions. When the i
```python
-print joy.library.definitions
+print(joy.library.definitions)
```
- ? == dup truthy
- *fraction == [uncons] dip uncons [swap] dip concat [*] infra [*] dip cons
- *fraction0 == concat [[swap] dip * [*] dip] infra
- anamorphism == [pop []] swap [dip swons] genrec
- average == [sum 1.0 *] [size] cleave /
- binary == nullary [popop] dip
- cleave == fork [popd] dip
- codireco == cons dip rest cons
- dinfrirst == dip infra first
- unstack == ? [uncons ?] loop pop
- down_to_zero == [0 >] [dup --] while
- dupdipd == dup dipd
- enstacken == stack [clear] dip
- flatten == [] swap [concat] step
- fork == [i] app2
- gcd == 1 [tuck modulus dup 0 >] loop pop
- ifte == [nullary not] dipd branch
- ii == [dip] dupdip i
- least_fraction == dup [gcd] infra [div] concat map
- make_generator == [codireco] ccons
- nullary == [stack] dinfrirst
- of == swap at
- pam == [i] map
- primrec == [i] genrec
- product == 1 swap [*] step
- quoted == [unit] dip
- range == [0 <=] [1 - dup] anamorphism
- range_to_zero == unit [down_to_zero] infra
- run == [] swap infra
- size == 0 swap [pop ++] step
- sqr == dup mul
- step_zero == 0 roll> step
- swoncat == swap concat
- ternary == unary [popop] dip
- unary == nullary popd
- unquoted == [i] dip
- while == swap [nullary] cons dup dipd concat loop
+ ? dup truthy
+ *fraction [uncons] dip uncons [swap] dip concat [*] infra [*] dip cons
+ *fraction0 concat [[swap] dip * [*] dip] infra
+ anamorphism [pop []] swap [dip swons] genrec
+ average [sum 1.0 *] [size] cleave /
+ binary nullary [popop] dip
+ cleave fork [popd] dip
+ codireco cons dip rest cons
+ dinfrirst dip infra first
+ unstack ? [uncons ?] loop pop
+ down_to_zero [0 >] [dup --] while
+ dupdipd dup dipd
+ enstacken stack [clear] dip
+ flatten [] swap [concat] step
+ fork [i] app2
+ gcd 1 [tuck modulus dup 0 >] loop pop
+ ifte [nullary not] dipd branch
+ ii [dip] dupdip i
+ least_fraction dup [gcd] infra [div] concat map
+ make_generator [codireco] ccons
+ nullary [stack] dinfrirst
+ of swap at
+ pam [i] map
+ tailrec [i] genrec
+ product 1 swap [*] step
+ quoted [unit] dip
+ range [0 <=] [1 - dup] anamorphism
+ range_to_zero unit [down_to_zero] infra
+ run [] swap infra
+ size 0 swap [pop ++] step
+ sqr dup mul
+ step_zero 0 roll> step
+ swoncat swap concat
+ tailrec [i] genrec
+ ternary unary [popop] dip
+ unary nullary popd
+ unquoted [i] dip
+ while swap [nullary] cons dup dipd concat loop
diff --git a/docs/0._This_Implementation_of_Joy_in_Python.rst b/docs/0._This_Implementation_of_Joy_in_Python.rst
index 80a196d..0227943 100644
--- a/docs/0._This_Implementation_of_Joy_in_Python.rst
+++ b/docs/0._This_Implementation_of_Joy_in_Python.rst
@@ -22,18 +22,18 @@ that you start by running the package:
::
- $ python -m joy
- Joypy - Copyright © 2017 Simon Forman
- This program comes with ABSOLUTELY NO WARRANTY; for details type "warranty".
- This is free software, and you are welcome to redistribute it
- under certain conditions; type "sharing" for details.
- Type "words" to see a list of all words, and "[] help" to print the
- docs for a word.
+ $ python -m joy
+ Joypy - Copyright © 2017 Simon Forman
+ This program comes with ABSOLUTELY NO WARRANTY; for details type "warranty".
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type "sharing" for details.
+ Type "words" to see a list of all words, and "[] help" to print the
+ docs for a word.
- <-top
+ <-top
- joy? _
+ joy? _
The ``<-top`` marker points to the top of the (initially empty) stack.
You can enter Joy notation at the prompt and a `trace of
@@ -42,18 +42,18 @@ and prompt again:
::
- joy? 23 sqr 18 +
- . 23 sqr 18 +
- 23 . sqr 18 +
- 23 . dup mul 18 +
- 23 23 . mul 18 +
- 529 . 18 +
- 529 18 . +
- 547 .
+ joy? 23 sqr 18 +
+ . 23 sqr 18 +
+ 23 . sqr 18 +
+ 23 . dup mul 18 +
+ 23 23 . mul 18 +
+ 529 . 18 +
+ 529 18 . +
+ 547 .
- 547 <-top
+ 547 <-top
- joy?
+ joy?
Stacks (aka list, quote, sequence, etc.)
========================================
@@ -65,13 +65,68 @@ both the stack and the expression. It is a `cons
list `__ made from Python
tuples.
-.. code:: ipython2
+.. code:: ipython3
import inspect
import joy.utils.stack
- print inspect.getdoc(joy.utils.stack)
+ print(inspect.getdoc(joy.utils.stack))
+
+
+.. parsed-literal::
+
+ When talking about Joy we use the terms "stack", "quote", "sequence",
+ "list", and others to mean the same thing: a simple linear datatype that
+ permits certain operations such as iterating and pushing and popping
+ values from (at least) one end.
+
+ There is no "Stack" Python class, instead we use the `cons list`_, a
+ venerable two-tuple recursive sequence datastructure, where the
+ empty tuple ``()`` is the empty stack and ``(head, rest)`` gives the
+ recursive form of a stack with one or more items on it::
+
+ stack := () | (item, stack)
+
+ Putting some numbers onto a stack::
+
+ ()
+ (1, ())
+ (2, (1, ()))
+ (3, (2, (1, ())))
+ ...
+
+ Python has very nice "tuple packing and unpacking" in its syntax which
+ means we can directly "unpack" the expected arguments to a Joy function.
+
+ For example::
+
+ def dup((head, tail)):
+ return head, (head, tail)
+
+ We replace the argument "stack" by the expected structure of the stack,
+ in this case "(head, tail)", and Python takes care of unpacking the
+ incoming tuple and assigning values to the names. (Note that Python
+ syntax doesn't require parentheses around tuples used in expressions
+ where they would be redundant.)
+
+ Unfortunately, the Sphinx documentation generator, which is used to generate this
+ web page, doesn't handle tuples in the function parameters. And in Python 3, this
+ syntax was removed entirely. Instead you would have to write::
+
+ def dup(stack):
+ head, tail = stack
+ return head, (head, tail)
+
+
+ We have two very simple functions, one to build up a stack from a Python
+ iterable and another to iterate through a stack and yield its items
+ one-by-one in order. There are also two functions to generate string representations
+ of stacks. They only differ in that one prints the terms in stack from left-to-right while the other prints from right-to-left. In both functions *internal stacks* are
+ printed left-to-right. These functions are written to support :doc:`../pretty`.
+
+ .. _cons list: https://en.wikipedia.org/wiki/Cons#Lists
+
The utility functions maintain order.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -79,32 +134,57 @@ The utility functions maintain order.
The 0th item in the list will be on the top of the stack and *vise
versa*.
-.. code:: ipython2
+.. code:: ipython3
joy.utils.stack.list_to_stack([1, 2, 3])
-.. code:: ipython2
+
+
+
+.. parsed-literal::
+
+ (1, (2, (3, ())))
+
+
+
+.. code:: ipython3
list(joy.utils.stack.iter_stack((1, (2, (3, ())))))
+
+
+
+.. parsed-literal::
+
+ [1, 2, 3]
+
+
+
This requires reversing the sequence (or iterating backwards) otherwise:
-.. code:: ipython2
+.. code:: ipython3
stack = ()
for n in [1, 2, 3]:
stack = n, stack
- print stack
- print list(joy.utils.stack.iter_stack(stack))
+ print(stack)
+ print(list(joy.utils.stack.iter_stack(stack)))
+
+
+.. parsed-literal::
+
+ (3, (2, (1, ())))
+ [3, 2, 1]
+
Purely Functional Datastructures.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Because Joy lists are made out of Python tuples they are immutable, so
-all Joy datastructures are `purely
-functional `__.
+all Joy datastructures are *`purely
+functional `__*.
The ``joy()`` function.
=======================
@@ -119,21 +199,58 @@ looks up in the dictionary.
Each function is passed the stack, expression, and dictionary and
returns them. Whatever the function returns becomes the new stack,
-expression, and dictionary. (The dictionary is passed to enable
-e.g. writing words that let you enter new words into the dictionary at
+expression, and dictionary. (The dictionary is passed to enable e.g.
+writing words that let you enter new words into the dictionary at
runtime, which nothing does yet and may be a bad idea, and the ``help``
command.)
-.. code:: ipython2
+.. code:: ipython3
import joy.joy
- print inspect.getsource(joy.joy.joy)
+ print(inspect.getsource(joy.joy.joy))
+
+
+.. parsed-literal::
+
+ def joy(stack, expression, dictionary, viewer=None):
+ '''Evaluate a Joy expression on a stack.
+
+ This function iterates through a sequence of terms which are either
+ literals (strings, numbers, sequences of terms) or function symbols.
+ Literals are put onto the stack and functions are looked up in the
+ disctionary and executed.
+
+ The viewer is a function that is called with the stack and expression
+ on every iteration, its return value is ignored.
+
+ :param stack stack: The stack.
+ :param stack expression: The expression to evaluate.
+ :param dict dictionary: A ``dict`` mapping names to Joy functions.
+ :param function viewer: Optional viewer function.
+ :rtype: (stack, (), dictionary)
+
+ '''
+ while expression:
+
+ if viewer: viewer(stack, expression)
+
+ term, expression = expression
+ if isinstance(term, Symbol):
+ term = dictionary[term]
+ stack, expression, dictionary = term(stack, expression, dictionary)
+ else:
+ stack = term, stack
+
+ if viewer: viewer(stack, expression)
+ return stack, expression, dictionary
+
+
View function
~~~~~~~~~~~~~
-The ``joy()`` function accepts a “viewer” function which it calls on
+The ``joy()`` function accepts a "viewer" function which it calls on
each iteration passing the current stack and expression just before
evaluation. This can be used for tracing, breakpoints, retrying after
exceptions, or interrupting an evaluation and saving to disk or sending
@@ -147,7 +264,7 @@ A ``viewer`` records each step of the evaluation of a Joy program. The
``TracePrinter`` has a facility for printing out a trace of the
evaluation, one line per step. Each step is aligned to the current
interpreter position, signified by a period separating the stack on the
-left from the pending expression (“continuation”) on the right.
+left from the pending expression ("continuation") on the right.
`Continuation-Passing Style `__
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -162,11 +279,11 @@ modifying the expression rather than making recursive calls to the
Parser
======
-.. code:: ipython2
+.. code:: ipython3
import joy.parser
- print inspect.getdoc(joy.parser)
+ print(inspect.getdoc(joy.parser))
.. parsed-literal::
@@ -191,12 +308,12 @@ Parser
The parser is extremely simple, the undocumented ``re.Scanner`` class
does most of the tokenizing work and then you just build the tuple
-structure out of the tokens. There’s no Abstract Syntax Tree or anything
+structure out of the tokens. There's no Abstract Syntax Tree or anything
like that.
-.. code:: ipython2
+.. code:: ipython3
- print inspect.getsource(joy.parser._parse)
+ print(inspect.getsource(joy.parser._parse))
.. parsed-literal::
@@ -226,9 +343,9 @@ like that.
-That’s pretty much all there is to it.
+That's pretty much all there is to it.
-.. code:: ipython2
+.. code:: ipython3
joy.parser.text_to_expression('1 2 3 4 5') # A simple sequence.
@@ -241,7 +358,7 @@ That’s pretty much all there is to it.
-.. code:: ipython2
+.. code:: ipython3
joy.parser.text_to_expression('[1 2 3] 4 5') # Three items, the first is a list with three items
@@ -254,7 +371,7 @@ That’s pretty much all there is to it.
-.. code:: ipython2
+.. code:: ipython3
joy.parser.text_to_expression('1 23 ["four" [-5.0] cons] 8888') # A mixed bag. cons is
# a Symbol, no lookup at
@@ -269,7 +386,7 @@ That’s pretty much all there is to it.
-.. code:: ipython2
+.. code:: ipython3
joy.parser.text_to_expression('[][][][][]') # Five empty lists.
@@ -282,7 +399,7 @@ That’s pretty much all there is to it.
-.. code:: ipython2
+.. code:: ipython3
joy.parser.text_to_expression('[[[[[]]]]]') # Five nested lists.
@@ -298,35 +415,34 @@ That’s pretty much all there is to it.
Library
=======
-The Joy library of functions (aka commands, or “words” after Forth
+The Joy library of functions (aka commands, or "words" after Forth
usage) encapsulates all the actual functionality (no pun intended) of
the Joy system. There are simple functions such as addition ``add`` (or
``+``, the library module supports aliases), and combinators which
provide control-flow and higher-order operations.
-.. code:: ipython2
+.. code:: ipython3
import joy.library
- print ' '.join(sorted(joy.library.initialize()))
+ print(' '.join(sorted(joy.library.initialize())))
.. parsed-literal::
- != % & * *fraction *fraction0 + ++ - -- / // /floor < << <= <> = > >= >> ? ^ _Tree_add_Ee _Tree_delete_R0 _Tree_delete_clear_stuff _Tree_get_E abs add anamorphism and app1 app2 app3 at average b binary bool branch ccons choice clear cleave cmp codireco concat cond cons dinfrirst dip dipd dipdd disenstacken divmod down_to_zero drop dup dupd dupdd dupdip dupdipd enstacken eq first first_two flatten floor floordiv fork fourth gcd ge genrec getitem gt help i id ifte ii infer infra inscribe le least_fraction loop lshift lt make_generator map max min mod modulus mul ne neg not nullary of or over pam parse pick pm pop popd popdd popop popopd popopdd pow pred primrec product quoted range range_to_zero rem remainder remove rest reverse roll< roll> rolldown rollup round rrest rshift run second select sharing shunt size sort sqr sqrt stack step step_zero stuncons stununcons sub succ sum swaack swap swoncat swons take ternary third times truediv truthy tuck unary uncons unique unit unquoted unstack unswons void warranty while words x xor zip •
+ != % & * *fraction *fraction0 + ++ - -- / // /floor < << <= <> = > >= >> ? ^ _Tree_add_Ee _Tree_delete_R0 _Tree_delete_clear_stuff _Tree_get_E abs add anamorphism and app1 app2 app3 at average b binary bool branch ccons choice clear cleave cmp codireco concat cond cons dinfrirst dip dipd dipdd disenstacken div divmod down_to_zero drop dup dupd dupdd dupdip dupdipd enstacken eq first first_two flatten floor floordiv fork fourth gcd ge genrec getitem gt help i id ifte ii infra inscribe le least_fraction loop lshift lt make_generator map max min mod modulus mul ne neg not nullary of or over pam parse pick pm pop popd popdd popop popopd popopdd pow pred primrec product quoted range range_to_zero rem remainder remove rest reverse roll< roll> rolldown rollup round rrest rshift run second select sharing shunt size sort sqr sqrt stack step step_zero stuncons stununcons sub succ sum swaack swap swoncat swons tailrec take ternary third times truediv truthy tuck unary uncons unique unit unquoted unstack unswons void warranty while words x xor zip •
Many of the functions are defined in Python, like ``dip``:
-.. code:: ipython2
+.. code:: ipython3
- print inspect.getsource(joy.library.dip)
+ print(inspect.getsource(joy.library.dip))
.. parsed-literal::
@inscribe
- @combinator_effect(_COMB_NUMS(), a1, s1)
@FunctionWrapper
def dip(stack, expression, dictionary):
'''
@@ -335,9 +451,9 @@ Many of the functions are defined in Python, like ``dip``:
on the rest of the stack.
::
- ... x [Q] dip
+ ... x [Q] dip
-------------------
- ... Q x
+ ... Q x
'''
(quote, (x, stack)) = stack
@@ -351,89 +467,90 @@ When the interpreter executes a definition function that function just
pushes its body expression onto the pending expression (the
continuation) and returns control to the interpreter.
-.. code:: ipython2
+.. code:: ipython3
- print joy.library.definitions
+ print(joy.library.definitions)
.. parsed-literal::
- ? == dup truthy
- *fraction == [uncons] dip uncons [swap] dip concat [*] infra [*] dip cons
- *fraction0 == concat [[swap] dip * [*] dip] infra
- anamorphism == [pop []] swap [dip swons] genrec
- average == [sum 1.0 *] [size] cleave /
- binary == nullary [popop] dip
- cleave == fork [popd] dip
- codireco == cons dip rest cons
- dinfrirst == dip infra first
- unstack == ? [uncons ?] loop pop
- down_to_zero == [0 >] [dup --] while
- dupdipd == dup dipd
- enstacken == stack [clear] dip
- flatten == [] swap [concat] step
- fork == [i] app2
- gcd == 1 [tuck modulus dup 0 >] loop pop
- ifte == [nullary not] dipd branch
- ii == [dip] dupdip i
- least_fraction == dup [gcd] infra [div] concat map
- make_generator == [codireco] ccons
- nullary == [stack] dinfrirst
- of == swap at
- pam == [i] map
- primrec == [i] genrec
- product == 1 swap [*] step
- quoted == [unit] dip
- range == [0 <=] [1 - dup] anamorphism
- range_to_zero == unit [down_to_zero] infra
- run == [] swap infra
- size == 0 swap [pop ++] step
- sqr == dup mul
- step_zero == 0 roll> step
- swoncat == swap concat
- ternary == unary [popop] dip
- unary == nullary popd
- unquoted == [i] dip
- while == swap [nullary] cons dup dipd concat loop
+ ? dup truthy
+ *fraction [uncons] dip uncons [swap] dip concat [*] infra [*] dip cons
+ *fraction0 concat [[swap] dip * [*] dip] infra
+ anamorphism [pop []] swap [dip swons] genrec
+ average [sum 1.0 *] [size] cleave /
+ binary nullary [popop] dip
+ cleave fork [popd] dip
+ codireco cons dip rest cons
+ dinfrirst dip infra first
+ unstack ? [uncons ?] loop pop
+ down_to_zero [0 >] [dup --] while
+ dupdipd dup dipd
+ enstacken stack [clear] dip
+ flatten [] swap [concat] step
+ fork [i] app2
+ gcd 1 [tuck modulus dup 0 >] loop pop
+ ifte [nullary not] dipd branch
+ ii [dip] dupdip i
+ least_fraction dup [gcd] infra [div] concat map
+ make_generator [codireco] ccons
+ nullary [stack] dinfrirst
+ of swap at
+ pam [i] map
+ tailrec [i] genrec
+ product 1 swap [*] step
+ quoted [unit] dip
+ range [0 <=] [1 - dup] anamorphism
+ range_to_zero unit [down_to_zero] infra
+ run [] swap infra
+ size 0 swap [pop ++] step
+ sqr dup mul
+ step_zero 0 roll> step
+ swoncat swap concat
+ tailrec [i] genrec
+ ternary unary [popop] dip
+ unary nullary popd
+ unquoted [i] dip
+ while swap [nullary] cons dup dipd concat loop
-Currently, there’s no function to add new definitions to the dictionary
-from “within” Joy code itself. Adding new definitions remains a
+Currently, there's no function to add new definitions to the dictionary
+from "within" Joy code itself. Adding new definitions remains a
meta-interpreter action. You have to do it yourself, in Python, and wash
your hands afterward.
It would be simple enough to define one, but it would open the door to
*name binding* and break the idea that all state is captured in the
-stack and expression. There’s an implicit *standard dictionary* that
+stack and expression. There's an implicit *standard dictionary* that
defines the actual semantics of the syntactic stack and expression
datastructures (which only contain symbols, not the actual functions.
Pickle some and see for yourself.)
-“There should be only one.”
+"There should be only one."
^^^^^^^^^^^^^^^^^^^^^^^^^^^
Which brings me to talking about one of my hopes and dreams for this
-notation: “There should be only one.” What I mean is that there should
+notation: "There should be only one." What I mean is that there should
be one universal standard dictionary of commands, and all bespoke work
done in a UI for purposes takes place by direct interaction and macros.
There would be a *Grand Refactoring* biannually (two years, not six
-months, that’s semi-annually) where any new definitions factored out of
+months, that's semi-annually) where any new definitions factored out of
the usage and macros of the previous time, along with new algorithms and
-such, were entered into the dictionary and posted to e.g. IPFS.
+such, were entered into the dictionary and posted to e.g. IPFS.
Code should not burgeon wildly, as it does today. The variety of code
should map more-or-less to the well-factored variety of human
-computably-solvable problems. There shouldn’t be dozens of chat apps, JS
-frameworks, programming languages. It’s a waste of time, a `fractal
-“thundering herd”
+computably-solvable problems. There shouldn't be dozens of chat apps, JS
+frameworks, programming languages. It's a waste of time, a `fractal
+"thundering herd"
attack `__ on
human mentality.
Literary Code Library
^^^^^^^^^^^^^^^^^^^^^
-If you read over the other notebooks you’ll see that developing code in
+If you read over the other notebooks you'll see that developing code in
Joy is a lot like doing simple mathematics, and the descriptions of the
code resemble math papers. The code also works the first time, no bugs.
If you have any experience programming at all, you are probably
diff --git a/docs/1._Basic_Use_of_Joy_in_a_Notebook.html b/docs/1._Basic_Use_of_Joy_in_a_Notebook.html
index 8698435..53a7d38 100644
--- a/docs/1._Basic_Use_of_Joy_in_a_Notebook.html
+++ b/docs/1._Basic_Use_of_Joy_in_a_Notebook.html
@@ -13087,7 +13087,7 @@ div#notebook {
In [1]:
-from joy.joy import run
+from joy.joy import run
from joy.library import initialize
from joy.utils.stack import stack_to_string
from joy.utils.pretty_print import TracePrinter
@@ -13111,12 +13111,12 @@ div#notebook {
In [2]:
-D = initialize()
+D = initialize()
S = ()
def J(text):
- print stack_to_string(run(text, S, D)[0])
+ print(stack_to_string(run(text, S, D)[0]))
def V(text):
@@ -13142,7 +13142,7 @@ div#notebook {
In [3]:
-J('23 18 +')
+J('23 18 +')
@@ -13173,7 +13173,7 @@ div#notebook {
In [4]:
-J('45 30 gcd')
+J('45 30 gcd')
@@ -13212,7 +13212,7 @@ div#notebook {
In [5]:
-V('23 18 +')
+V('23 18 +')
@@ -13229,10 +13229,10 @@ div#notebook {
- . 23 18 +
- 23 . 18 +
-23 18 . +
- 41 .
+ • 23 18 +
+ 23 • 18 +
+23 18 • +
+ 41 •
@@ -13246,7 +13246,7 @@ div#notebook {
In [6]:
-V('45 30 gcd')
+V('45 30 gcd')
@@ -13263,28 +13263,28 @@ div#notebook {
- . 45 30 gcd
- 45 . 30 gcd
- 45 30 . gcd
- 45 30 . 1 [tuck modulus dup 0 >] loop pop
- 45 30 1 . [tuck modulus dup 0 >] loop pop
- 45 30 1 [tuck modulus dup 0 >] . loop pop
- 45 30 . tuck modulus dup 0 > [tuck modulus dup 0 >] loop pop
- 30 45 30 . modulus dup 0 > [tuck modulus dup 0 >] loop pop
- 30 15 . dup 0 > [tuck modulus dup 0 >] loop pop
- 30 15 15 . 0 > [tuck modulus dup 0 >] loop pop
- 30 15 15 0 . > [tuck modulus dup 0 >] loop pop
- 30 15 True . [tuck modulus dup 0 >] loop pop
-30 15 True [tuck modulus dup 0 >] . loop pop
- 30 15 . tuck modulus dup 0 > [tuck modulus dup 0 >] loop pop
- 15 30 15 . modulus dup 0 > [tuck modulus dup 0 >] loop pop
- 15 0 . dup 0 > [tuck modulus dup 0 >] loop pop
- 15 0 0 . 0 > [tuck modulus dup 0 >] loop pop
- 15 0 0 0 . > [tuck modulus dup 0 >] loop pop
- 15 0 False . [tuck modulus dup 0 >] loop pop
-15 0 False [tuck modulus dup 0 >] . loop pop
- 15 0 . pop
- 15 .
+ • 45 30 gcd
+ 45 • 30 gcd
+ 45 30 • gcd
+ 45 30 • 1 [tuck modulus dup 0 >] loop pop
+ 45 30 1 • [tuck modulus dup 0 >] loop pop
+ 45 30 1 [tuck modulus dup 0 >] • loop pop
+ 45 30 • tuck modulus dup 0 > [tuck modulus dup 0 >] loop pop
+ 30 45 30 • modulus dup 0 > [tuck modulus dup 0 >] loop pop
+ 30 15 • dup 0 > [tuck modulus dup 0 >] loop pop
+ 30 15 15 • 0 > [tuck modulus dup 0 >] loop pop
+ 30 15 15 0 • > [tuck modulus dup 0 >] loop pop
+ 30 15 True • [tuck modulus dup 0 >] loop pop
+30 15 True [tuck modulus dup 0 >] • loop pop
+ 30 15 • tuck modulus dup 0 > [tuck modulus dup 0 >] loop pop
+ 15 30 15 • modulus dup 0 > [tuck modulus dup 0 >] loop pop
+ 15 0 • dup 0 > [tuck modulus dup 0 >] loop pop
+ 15 0 0 • 0 > [tuck modulus dup 0 >] loop pop
+ 15 0 0 0 • > [tuck modulus dup 0 >] loop pop
+ 15 0 False • [tuck modulus dup 0 >] loop pop
+15 0 False [tuck modulus dup 0 >] • loop pop
+ 15 0 • pop
+ 15 •
@@ -13306,7 +13306,7 @@ div#notebook {
In [7]:
-V('96 27 gcd')
+V('96 27 gcd')
@@ -13323,42 +13323,42 @@ div#notebook {
- . 96 27 gcd
- 96 . 27 gcd
- 96 27 . gcd
- 96 27 . 1 [tuck modulus dup 0 >] loop pop
- 96 27 1 . [tuck modulus dup 0 >] loop pop
- 96 27 1 [tuck modulus dup 0 >] . loop pop
- 96 27 . tuck modulus dup 0 > [tuck modulus dup 0 >] loop pop
- 27 96 27 . modulus dup 0 > [tuck modulus dup 0 >] loop pop
- 27 15 . dup 0 > [tuck modulus dup 0 >] loop pop
- 27 15 15 . 0 > [tuck modulus dup 0 >] loop pop
- 27 15 15 0 . > [tuck modulus dup 0 >] loop pop
- 27 15 True . [tuck modulus dup 0 >] loop pop
-27 15 True [tuck modulus dup 0 >] . loop pop
- 27 15 . tuck modulus dup 0 > [tuck modulus dup 0 >] loop pop
- 15 27 15 . modulus dup 0 > [tuck modulus dup 0 >] loop pop
- 15 12 . dup 0 > [tuck modulus dup 0 >] loop pop
- 15 12 12 . 0 > [tuck modulus dup 0 >] loop pop
- 15 12 12 0 . > [tuck modulus dup 0 >] loop pop
- 15 12 True . [tuck modulus dup 0 >] loop pop
-15 12 True [tuck modulus dup 0 >] . loop pop
- 15 12 . tuck modulus dup 0 > [tuck modulus dup 0 >] loop pop
- 12 15 12 . modulus dup 0 > [tuck modulus dup 0 >] loop pop
- 12 3 . dup 0 > [tuck modulus dup 0 >] loop pop
- 12 3 3 . 0 > [tuck modulus dup 0 >] loop pop
- 12 3 3 0 . > [tuck modulus dup 0 >] loop pop
- 12 3 True . [tuck modulus dup 0 >] loop pop
- 12 3 True [tuck modulus dup 0 >] . loop pop
- 12 3 . tuck modulus dup 0 > [tuck modulus dup 0 >] loop pop
- 3 12 3 . modulus dup 0 > [tuck modulus dup 0 >] loop pop
- 3 0 . dup 0 > [tuck modulus dup 0 >] loop pop
- 3 0 0 . 0 > [tuck modulus dup 0 >] loop pop
- 3 0 0 0 . > [tuck modulus dup 0 >] loop pop
- 3 0 False . [tuck modulus dup 0 >] loop pop
- 3 0 False [tuck modulus dup 0 >] . loop pop
- 3 0 . pop
- 3 .
+ • 96 27 gcd
+ 96 • 27 gcd
+ 96 27 • gcd
+ 96 27 • 1 [tuck modulus dup 0 >] loop pop
+ 96 27 1 • [tuck modulus dup 0 >] loop pop
+ 96 27 1 [tuck modulus dup 0 >] • loop pop
+ 96 27 • tuck modulus dup 0 > [tuck modulus dup 0 >] loop pop
+ 27 96 27 • modulus dup 0 > [tuck modulus dup 0 >] loop pop
+ 27 15 • dup 0 > [tuck modulus dup 0 >] loop pop
+ 27 15 15 • 0 > [tuck modulus dup 0 >] loop pop
+ 27 15 15 0 • > [tuck modulus dup 0 >] loop pop
+ 27 15 True • [tuck modulus dup 0 >] loop pop
+27 15 True [tuck modulus dup 0 >] • loop pop
+ 27 15 • tuck modulus dup 0 > [tuck modulus dup 0 >] loop pop
+ 15 27 15 • modulus dup 0 > [tuck modulus dup 0 >] loop pop
+ 15 12 • dup 0 > [tuck modulus dup 0 >] loop pop
+ 15 12 12 • 0 > [tuck modulus dup 0 >] loop pop
+ 15 12 12 0 • > [tuck modulus dup 0 >] loop pop
+ 15 12 True • [tuck modulus dup 0 >] loop pop
+15 12 True [tuck modulus dup 0 >] • loop pop
+ 15 12 • tuck modulus dup 0 > [tuck modulus dup 0 >] loop pop
+ 12 15 12 • modulus dup 0 > [tuck modulus dup 0 >] loop pop
+ 12 3 • dup 0 > [tuck modulus dup 0 >] loop pop
+ 12 3 3 • 0 > [tuck modulus dup 0 >] loop pop
+ 12 3 3 0 • > [tuck modulus dup 0 >] loop pop
+ 12 3 True • [tuck modulus dup 0 >] loop pop
+ 12 3 True [tuck modulus dup 0 >] • loop pop
+ 12 3 • tuck modulus dup 0 > [tuck modulus dup 0 >] loop pop
+ 3 12 3 • modulus dup 0 > [tuck modulus dup 0 >] loop pop
+ 3 0 • dup 0 > [tuck modulus dup 0 >] loop pop
+ 3 0 0 • 0 > [tuck modulus dup 0 >] loop pop
+ 3 0 0 0 • > [tuck modulus dup 0 >] loop pop
+ 3 0 False • [tuck modulus dup 0 >] loop pop
+ 3 0 False [tuck modulus dup 0 >] • loop pop
+ 3 0 • pop
+ 3 •
@@ -13366,19 +13366,6 @@ div#notebook {
-
-
-
-In [ ]:
-
-
-
-
-
-
-
-
-
diff --git a/docs/1._Basic_Use_of_Joy_in_a_Notebook.ipynb b/docs/1._Basic_Use_of_Joy_in_a_Notebook.ipynb
index de6487b..b388fdb 100644
--- a/docs/1._Basic_Use_of_Joy_in_a_Notebook.ipynb
+++ b/docs/1._Basic_Use_of_Joy_in_a_Notebook.ipynb
@@ -39,7 +39,7 @@
"\n",
"\n",
"def J(text):\n",
- " print stack_to_string(run(text, S, D)[0])\n",
+ " print(stack_to_string(run(text, S, D)[0]))\n",
"\n",
"\n",
"def V(text):\n",
@@ -107,10 +107,10 @@
"name": "stdout",
"output_type": "stream",
"text": [
- " . 23 18 +\n",
- " 23 . 18 +\n",
- "23 18 . +\n",
- " 41 . \n"
+ " • 23 18 +\n",
+ " 23 • 18 +\n",
+ "23 18 • +\n",
+ " 41 • \n"
]
}
],
@@ -127,28 +127,28 @@
"name": "stdout",
"output_type": "stream",
"text": [
- " . 45 30 gcd\n",
- " 45 . 30 gcd\n",
- " 45 30 . gcd\n",
- " 45 30 . 1 [tuck modulus dup 0 >] loop pop\n",
- " 45 30 1 . [tuck modulus dup 0 >] loop pop\n",
- " 45 30 1 [tuck modulus dup 0 >] . loop pop\n",
- " 45 30 . tuck modulus dup 0 > [tuck modulus dup 0 >] loop pop\n",
- " 30 45 30 . modulus dup 0 > [tuck modulus dup 0 >] loop pop\n",
- " 30 15 . dup 0 > [tuck modulus dup 0 >] loop pop\n",
- " 30 15 15 . 0 > [tuck modulus dup 0 >] loop pop\n",
- " 30 15 15 0 . > [tuck modulus dup 0 >] loop pop\n",
- " 30 15 True . [tuck modulus dup 0 >] loop pop\n",
- "30 15 True [tuck modulus dup 0 >] . loop pop\n",
- " 30 15 . tuck modulus dup 0 > [tuck modulus dup 0 >] loop pop\n",
- " 15 30 15 . modulus dup 0 > [tuck modulus dup 0 >] loop pop\n",
- " 15 0 . dup 0 > [tuck modulus dup 0 >] loop pop\n",
- " 15 0 0 . 0 > [tuck modulus dup 0 >] loop pop\n",
- " 15 0 0 0 . > [tuck modulus dup 0 >] loop pop\n",
- " 15 0 False . [tuck modulus dup 0 >] loop pop\n",
- "15 0 False [tuck modulus dup 0 >] . loop pop\n",
- " 15 0 . pop\n",
- " 15 . \n"
+ " • 45 30 gcd\n",
+ " 45 • 30 gcd\n",
+ " 45 30 • gcd\n",
+ " 45 30 • 1 [tuck modulus dup 0 >] loop pop\n",
+ " 45 30 1 • [tuck modulus dup 0 >] loop pop\n",
+ " 45 30 1 [tuck modulus dup 0 >] • loop pop\n",
+ " 45 30 • tuck modulus dup 0 > [tuck modulus dup 0 >] loop pop\n",
+ " 30 45 30 • modulus dup 0 > [tuck modulus dup 0 >] loop pop\n",
+ " 30 15 • dup 0 > [tuck modulus dup 0 >] loop pop\n",
+ " 30 15 15 • 0 > [tuck modulus dup 0 >] loop pop\n",
+ " 30 15 15 0 • > [tuck modulus dup 0 >] loop pop\n",
+ " 30 15 True • [tuck modulus dup 0 >] loop pop\n",
+ "30 15 True [tuck modulus dup 0 >] • loop pop\n",
+ " 30 15 • tuck modulus dup 0 > [tuck modulus dup 0 >] loop pop\n",
+ " 15 30 15 • modulus dup 0 > [tuck modulus dup 0 >] loop pop\n",
+ " 15 0 • dup 0 > [tuck modulus dup 0 >] loop pop\n",
+ " 15 0 0 • 0 > [tuck modulus dup 0 >] loop pop\n",
+ " 15 0 0 0 • > [tuck modulus dup 0 >] loop pop\n",
+ " 15 0 False • [tuck modulus dup 0 >] loop pop\n",
+ "15 0 False [tuck modulus dup 0 >] • loop pop\n",
+ " 15 0 • pop\n",
+ " 15 • \n"
]
}
],
@@ -172,55 +172,48 @@
"name": "stdout",
"output_type": "stream",
"text": [
- " . 96 27 gcd\n",
- " 96 . 27 gcd\n",
- " 96 27 . gcd\n",
- " 96 27 . 1 [tuck modulus dup 0 >] loop pop\n",
- " 96 27 1 . [tuck modulus dup 0 >] loop pop\n",
- " 96 27 1 [tuck modulus dup 0 >] . loop pop\n",
- " 96 27 . tuck modulus dup 0 > [tuck modulus dup 0 >] loop pop\n",
- " 27 96 27 . modulus dup 0 > [tuck modulus dup 0 >] loop pop\n",
- " 27 15 . dup 0 > [tuck modulus dup 0 >] loop pop\n",
- " 27 15 15 . 0 > [tuck modulus dup 0 >] loop pop\n",
- " 27 15 15 0 . > [tuck modulus dup 0 >] loop pop\n",
- " 27 15 True . [tuck modulus dup 0 >] loop pop\n",
- "27 15 True [tuck modulus dup 0 >] . loop pop\n",
- " 27 15 . tuck modulus dup 0 > [tuck modulus dup 0 >] loop pop\n",
- " 15 27 15 . modulus dup 0 > [tuck modulus dup 0 >] loop pop\n",
- " 15 12 . dup 0 > [tuck modulus dup 0 >] loop pop\n",
- " 15 12 12 . 0 > [tuck modulus dup 0 >] loop pop\n",
- " 15 12 12 0 . > [tuck modulus dup 0 >] loop pop\n",
- " 15 12 True . [tuck modulus dup 0 >] loop pop\n",
- "15 12 True [tuck modulus dup 0 >] . loop pop\n",
- " 15 12 . tuck modulus dup 0 > [tuck modulus dup 0 >] loop pop\n",
- " 12 15 12 . modulus dup 0 > [tuck modulus dup 0 >] loop pop\n",
- " 12 3 . dup 0 > [tuck modulus dup 0 >] loop pop\n",
- " 12 3 3 . 0 > [tuck modulus dup 0 >] loop pop\n",
- " 12 3 3 0 . > [tuck modulus dup 0 >] loop pop\n",
- " 12 3 True . [tuck modulus dup 0 >] loop pop\n",
- " 12 3 True [tuck modulus dup 0 >] . loop pop\n",
- " 12 3 . tuck modulus dup 0 > [tuck modulus dup 0 >] loop pop\n",
- " 3 12 3 . modulus dup 0 > [tuck modulus dup 0 >] loop pop\n",
- " 3 0 . dup 0 > [tuck modulus dup 0 >] loop pop\n",
- " 3 0 0 . 0 > [tuck modulus dup 0 >] loop pop\n",
- " 3 0 0 0 . > [tuck modulus dup 0 >] loop pop\n",
- " 3 0 False . [tuck modulus dup 0 >] loop pop\n",
- " 3 0 False [tuck modulus dup 0 >] . loop pop\n",
- " 3 0 . pop\n",
- " 3 . \n"
+ " • 96 27 gcd\n",
+ " 96 • 27 gcd\n",
+ " 96 27 • gcd\n",
+ " 96 27 • 1 [tuck modulus dup 0 >] loop pop\n",
+ " 96 27 1 • [tuck modulus dup 0 >] loop pop\n",
+ " 96 27 1 [tuck modulus dup 0 >] • loop pop\n",
+ " 96 27 • tuck modulus dup 0 > [tuck modulus dup 0 >] loop pop\n",
+ " 27 96 27 • modulus dup 0 > [tuck modulus dup 0 >] loop pop\n",
+ " 27 15 • dup 0 > [tuck modulus dup 0 >] loop pop\n",
+ " 27 15 15 • 0 > [tuck modulus dup 0 >] loop pop\n",
+ " 27 15 15 0 • > [tuck modulus dup 0 >] loop pop\n",
+ " 27 15 True • [tuck modulus dup 0 >] loop pop\n",
+ "27 15 True [tuck modulus dup 0 >] • loop pop\n",
+ " 27 15 • tuck modulus dup 0 > [tuck modulus dup 0 >] loop pop\n",
+ " 15 27 15 • modulus dup 0 > [tuck modulus dup 0 >] loop pop\n",
+ " 15 12 • dup 0 > [tuck modulus dup 0 >] loop pop\n",
+ " 15 12 12 • 0 > [tuck modulus dup 0 >] loop pop\n",
+ " 15 12 12 0 • > [tuck modulus dup 0 >] loop pop\n",
+ " 15 12 True • [tuck modulus dup 0 >] loop pop\n",
+ "15 12 True [tuck modulus dup 0 >] • loop pop\n",
+ " 15 12 • tuck modulus dup 0 > [tuck modulus dup 0 >] loop pop\n",
+ " 12 15 12 • modulus dup 0 > [tuck modulus dup 0 >] loop pop\n",
+ " 12 3 • dup 0 > [tuck modulus dup 0 >] loop pop\n",
+ " 12 3 3 • 0 > [tuck modulus dup 0 >] loop pop\n",
+ " 12 3 3 0 • > [tuck modulus dup 0 >] loop pop\n",
+ " 12 3 True • [tuck modulus dup 0 >] loop pop\n",
+ " 12 3 True [tuck modulus dup 0 >] • loop pop\n",
+ " 12 3 • tuck modulus dup 0 > [tuck modulus dup 0 >] loop pop\n",
+ " 3 12 3 • modulus dup 0 > [tuck modulus dup 0 >] loop pop\n",
+ " 3 0 • dup 0 > [tuck modulus dup 0 >] loop pop\n",
+ " 3 0 0 • 0 > [tuck modulus dup 0 >] loop pop\n",
+ " 3 0 0 0 • > [tuck modulus dup 0 >] loop pop\n",
+ " 3 0 False • [tuck modulus dup 0 >] loop pop\n",
+ " 3 0 False [tuck modulus dup 0 >] • loop pop\n",
+ " 3 0 • pop\n",
+ " 3 • \n"
]
}
],
"source": [
"V('96 27 gcd')"
]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": []
}
],
"metadata": {
@@ -232,14 +225,14 @@
"language_info": {
"codemirror_mode": {
"name": "ipython",
- "version": 2
+ "version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
- "pygments_lexer": "ipython2",
- "version": "2.7.12"
+ "pygments_lexer": "ipython3",
+ "version": "3.8.3"
}
},
"nbformat": 4,
diff --git a/docs/1._Basic_Use_of_Joy_in_a_Notebook.md b/docs/1._Basic_Use_of_Joy_in_a_Notebook.md
index 6f983fe..977bbb1 100644
--- a/docs/1._Basic_Use_of_Joy_in_a_Notebook.md
+++ b/docs/1._Basic_Use_of_Joy_in_a_Notebook.md
@@ -19,7 +19,7 @@ S = ()
def J(text):
- print stack_to_string(run(text, S, D)[0])
+ print(stack_to_string(run(text, S, D)[0]))
def V(text):
@@ -55,10 +55,10 @@ A `viewer` records each step of the evaluation of a Joy program. The `TracePrin
V('23 18 +')
```
- . 23 18 +
- 23 . 18 +
- 23 18 . +
- 41 .
+ • 23 18 +
+ 23 • 18 +
+ 23 18 • +
+ 41 •
@@ -66,28 +66,28 @@ V('23 18 +')
V('45 30 gcd')
```
- . 45 30 gcd
- 45 . 30 gcd
- 45 30 . gcd
- 45 30 . 1 [tuck modulus dup 0 >] loop pop
- 45 30 1 . [tuck modulus dup 0 >] loop pop
- 45 30 1 [tuck modulus dup 0 >] . loop pop
- 45 30 . tuck modulus dup 0 > [tuck modulus dup 0 >] loop pop
- 30 45 30 . modulus dup 0 > [tuck modulus dup 0 >] loop pop
- 30 15 . dup 0 > [tuck modulus dup 0 >] loop pop
- 30 15 15 . 0 > [tuck modulus dup 0 >] loop pop
- 30 15 15 0 . > [tuck modulus dup 0 >] loop pop
- 30 15 True . [tuck modulus dup 0 >] loop pop
- 30 15 True [tuck modulus dup 0 >] . loop pop
- 30 15 . tuck modulus dup 0 > [tuck modulus dup 0 >] loop pop
- 15 30 15 . modulus dup 0 > [tuck modulus dup 0 >] loop pop
- 15 0 . dup 0 > [tuck modulus dup 0 >] loop pop
- 15 0 0 . 0 > [tuck modulus dup 0 >] loop pop
- 15 0 0 0 . > [tuck modulus dup 0 >] loop pop
- 15 0 False . [tuck modulus dup 0 >] loop pop
- 15 0 False [tuck modulus dup 0 >] . loop pop
- 15 0 . pop
- 15 .
+ • 45 30 gcd
+ 45 • 30 gcd
+ 45 30 • gcd
+ 45 30 • 1 [tuck modulus dup 0 >] loop pop
+ 45 30 1 • [tuck modulus dup 0 >] loop pop
+ 45 30 1 [tuck modulus dup 0 >] • loop pop
+ 45 30 • tuck modulus dup 0 > [tuck modulus dup 0 >] loop pop
+ 30 45 30 • modulus dup 0 > [tuck modulus dup 0 >] loop pop
+ 30 15 • dup 0 > [tuck modulus dup 0 >] loop pop
+ 30 15 15 • 0 > [tuck modulus dup 0 >] loop pop
+ 30 15 15 0 • > [tuck modulus dup 0 >] loop pop
+ 30 15 True • [tuck modulus dup 0 >] loop pop
+ 30 15 True [tuck modulus dup 0 >] • loop pop
+ 30 15 • tuck modulus dup 0 > [tuck modulus dup 0 >] loop pop
+ 15 30 15 • modulus dup 0 > [tuck modulus dup 0 >] loop pop
+ 15 0 • dup 0 > [tuck modulus dup 0 >] loop pop
+ 15 0 0 • 0 > [tuck modulus dup 0 >] loop pop
+ 15 0 0 0 • > [tuck modulus dup 0 >] loop pop
+ 15 0 False • [tuck modulus dup 0 >] loop pop
+ 15 0 False [tuck modulus dup 0 >] • loop pop
+ 15 0 • pop
+ 15 •
Here's a longer trace.
@@ -97,45 +97,40 @@ Here's a longer trace.
V('96 27 gcd')
```
- . 96 27 gcd
- 96 . 27 gcd
- 96 27 . gcd
- 96 27 . 1 [tuck modulus dup 0 >] loop pop
- 96 27 1 . [tuck modulus dup 0 >] loop pop
- 96 27 1 [tuck modulus dup 0 >] . loop pop
- 96 27 . tuck modulus dup 0 > [tuck modulus dup 0 >] loop pop
- 27 96 27 . modulus dup 0 > [tuck modulus dup 0 >] loop pop
- 27 15 . dup 0 > [tuck modulus dup 0 >] loop pop
- 27 15 15 . 0 > [tuck modulus dup 0 >] loop pop
- 27 15 15 0 . > [tuck modulus dup 0 >] loop pop
- 27 15 True . [tuck modulus dup 0 >] loop pop
- 27 15 True [tuck modulus dup 0 >] . loop pop
- 27 15 . tuck modulus dup 0 > [tuck modulus dup 0 >] loop pop
- 15 27 15 . modulus dup 0 > [tuck modulus dup 0 >] loop pop
- 15 12 . dup 0 > [tuck modulus dup 0 >] loop pop
- 15 12 12 . 0 > [tuck modulus dup 0 >] loop pop
- 15 12 12 0 . > [tuck modulus dup 0 >] loop pop
- 15 12 True . [tuck modulus dup 0 >] loop pop
- 15 12 True [tuck modulus dup 0 >] . loop pop
- 15 12 . tuck modulus dup 0 > [tuck modulus dup 0 >] loop pop
- 12 15 12 . modulus dup 0 > [tuck modulus dup 0 >] loop pop
- 12 3 . dup 0 > [tuck modulus dup 0 >] loop pop
- 12 3 3 . 0 > [tuck modulus dup 0 >] loop pop
- 12 3 3 0 . > [tuck modulus dup 0 >] loop pop
- 12 3 True . [tuck modulus dup 0 >] loop pop
- 12 3 True [tuck modulus dup 0 >] . loop pop
- 12 3 . tuck modulus dup 0 > [tuck modulus dup 0 >] loop pop
- 3 12 3 . modulus dup 0 > [tuck modulus dup 0 >] loop pop
- 3 0 . dup 0 > [tuck modulus dup 0 >] loop pop
- 3 0 0 . 0 > [tuck modulus dup 0 >] loop pop
- 3 0 0 0 . > [tuck modulus dup 0 >] loop pop
- 3 0 False . [tuck modulus dup 0 >] loop pop
- 3 0 False [tuck modulus dup 0 >] . loop pop
- 3 0 . pop
- 3 .
+ • 96 27 gcd
+ 96 • 27 gcd
+ 96 27 • gcd
+ 96 27 • 1 [tuck modulus dup 0 >] loop pop
+ 96 27 1 • [tuck modulus dup 0 >] loop pop
+ 96 27 1 [tuck modulus dup 0 >] • loop pop
+ 96 27 • tuck modulus dup 0 > [tuck modulus dup 0 >] loop pop
+ 27 96 27 • modulus dup 0 > [tuck modulus dup 0 >] loop pop
+ 27 15 • dup 0 > [tuck modulus dup 0 >] loop pop
+ 27 15 15 • 0 > [tuck modulus dup 0 >] loop pop
+ 27 15 15 0 • > [tuck modulus dup 0 >] loop pop
+ 27 15 True • [tuck modulus dup 0 >] loop pop
+ 27 15 True [tuck modulus dup 0 >] • loop pop
+ 27 15 • tuck modulus dup 0 > [tuck modulus dup 0 >] loop pop
+ 15 27 15 • modulus dup 0 > [tuck modulus dup 0 >] loop pop
+ 15 12 • dup 0 > [tuck modulus dup 0 >] loop pop
+ 15 12 12 • 0 > [tuck modulus dup 0 >] loop pop
+ 15 12 12 0 • > [tuck modulus dup 0 >] loop pop
+ 15 12 True • [tuck modulus dup 0 >] loop pop
+ 15 12 True [tuck modulus dup 0 >] • loop pop
+ 15 12 • tuck modulus dup 0 > [tuck modulus dup 0 >] loop pop
+ 12 15 12 • modulus dup 0 > [tuck modulus dup 0 >] loop pop
+ 12 3 • dup 0 > [tuck modulus dup 0 >] loop pop
+ 12 3 3 • 0 > [tuck modulus dup 0 >] loop pop
+ 12 3 3 0 • > [tuck modulus dup 0 >] loop pop
+ 12 3 True • [tuck modulus dup 0 >] loop pop
+ 12 3 True [tuck modulus dup 0 >] • loop pop
+ 12 3 • tuck modulus dup 0 > [tuck modulus dup 0 >] loop pop
+ 3 12 3 • modulus dup 0 > [tuck modulus dup 0 >] loop pop
+ 3 0 • dup 0 > [tuck modulus dup 0 >] loop pop
+ 3 0 0 • 0 > [tuck modulus dup 0 >] loop pop
+ 3 0 0 0 • > [tuck modulus dup 0 >] loop pop
+ 3 0 False • [tuck modulus dup 0 >] loop pop
+ 3 0 False [tuck modulus dup 0 >] • loop pop
+ 3 0 • pop
+ 3 •
-
-
-```python
-
-```
diff --git a/docs/1._Basic_Use_of_Joy_in_a_Notebook.rst b/docs/1._Basic_Use_of_Joy_in_a_Notebook.rst
index 6f7a4cd..d928838 100644
--- a/docs/1._Basic_Use_of_Joy_in_a_Notebook.rst
+++ b/docs/1._Basic_Use_of_Joy_in_a_Notebook.rst
@@ -3,7 +3,7 @@ Preamble
First, import what we need.
-.. code:: ipython2
+.. code:: ipython3
from joy.joy import run
from joy.library import initialize
@@ -13,14 +13,14 @@ First, import what we need.
Define a dictionary, an initial stack, and two helper functions to run
Joy code and print results for us.
-.. code:: ipython2
+.. code:: ipython3
D = initialize()
S = ()
def J(text):
- print stack_to_string(run(text, S, D)[0])
+ print(stack_to_string(run(text, S, D)[0]))
def V(text):
@@ -31,7 +31,7 @@ Joy code and print results for us.
Run some simple programs
~~~~~~~~~~~~~~~~~~~~~~~~
-.. code:: ipython2
+.. code:: ipython3
J('23 18 +')
@@ -41,7 +41,7 @@ Run some simple programs
41
-.. code:: ipython2
+.. code:: ipython3
J('45 30 gcd')
@@ -58,97 +58,96 @@ A ``viewer`` records each step of the evaluation of a Joy program. The
``TracePrinter`` has a facility for printing out a trace of the
evaluation, one line per step. Each step is aligned to the current
interpreter position, signified by a period separating the stack on the
-left from the pending expression (“continuation”) on the right. I find
+left from the pending expression ("continuation") on the right. I find
these traces beautiful, like a kind of art.
-.. code:: ipython2
+.. code:: ipython3
V('23 18 +')
.. parsed-literal::
- . 23 18 +
- 23 . 18 +
- 23 18 . +
- 41 .
+ • 23 18 +
+ 23 • 18 +
+ 23 18 • +
+ 41 •
-.. code:: ipython2
+.. code:: ipython3
V('45 30 gcd')
.. parsed-literal::
- . 45 30 gcd
- 45 . 30 gcd
- 45 30 . gcd
- 45 30 . 1 [tuck modulus dup 0 >] loop pop
- 45 30 1 . [tuck modulus dup 0 >] loop pop
- 45 30 1 [tuck modulus dup 0 >] . loop pop
- 45 30 . tuck modulus dup 0 > [tuck modulus dup 0 >] loop pop
- 30 45 30 . modulus dup 0 > [tuck modulus dup 0 >] loop pop
- 30 15 . dup 0 > [tuck modulus dup 0 >] loop pop
- 30 15 15 . 0 > [tuck modulus dup 0 >] loop pop
- 30 15 15 0 . > [tuck modulus dup 0 >] loop pop
- 30 15 True . [tuck modulus dup 0 >] loop pop
- 30 15 True [tuck modulus dup 0 >] . loop pop
- 30 15 . tuck modulus dup 0 > [tuck modulus dup 0 >] loop pop
- 15 30 15 . modulus dup 0 > [tuck modulus dup 0 >] loop pop
- 15 0 . dup 0 > [tuck modulus dup 0 >] loop pop
- 15 0 0 . 0 > [tuck modulus dup 0 >] loop pop
- 15 0 0 0 . > [tuck modulus dup 0 >] loop pop
- 15 0 False . [tuck modulus dup 0 >] loop pop
- 15 0 False [tuck modulus dup 0 >] . loop pop
- 15 0 . pop
- 15 .
+ • 45 30 gcd
+ 45 • 30 gcd
+ 45 30 • gcd
+ 45 30 • 1 [tuck modulus dup 0 >] loop pop
+ 45 30 1 • [tuck modulus dup 0 >] loop pop
+ 45 30 1 [tuck modulus dup 0 >] • loop pop
+ 45 30 • tuck modulus dup 0 > [tuck modulus dup 0 >] loop pop
+ 30 45 30 • modulus dup 0 > [tuck modulus dup 0 >] loop pop
+ 30 15 • dup 0 > [tuck modulus dup 0 >] loop pop
+ 30 15 15 • 0 > [tuck modulus dup 0 >] loop pop
+ 30 15 15 0 • > [tuck modulus dup 0 >] loop pop
+ 30 15 True • [tuck modulus dup 0 >] loop pop
+ 30 15 True [tuck modulus dup 0 >] • loop pop
+ 30 15 • tuck modulus dup 0 > [tuck modulus dup 0 >] loop pop
+ 15 30 15 • modulus dup 0 > [tuck modulus dup 0 >] loop pop
+ 15 0 • dup 0 > [tuck modulus dup 0 >] loop pop
+ 15 0 0 • 0 > [tuck modulus dup 0 >] loop pop
+ 15 0 0 0 • > [tuck modulus dup 0 >] loop pop
+ 15 0 False • [tuck modulus dup 0 >] loop pop
+ 15 0 False [tuck modulus dup 0 >] • loop pop
+ 15 0 • pop
+ 15 •
-Here’s a longer trace.
+Here's a longer trace.
-.. code:: ipython2
+.. code:: ipython3
V('96 27 gcd')
.. parsed-literal::
- . 96 27 gcd
- 96 . 27 gcd
- 96 27 . gcd
- 96 27 . 1 [tuck modulus dup 0 >] loop pop
- 96 27 1 . [tuck modulus dup 0 >] loop pop
- 96 27 1 [tuck modulus dup 0 >] . loop pop
- 96 27 . tuck modulus dup 0 > [tuck modulus dup 0 >] loop pop
- 27 96 27 . modulus dup 0 > [tuck modulus dup 0 >] loop pop
- 27 15 . dup 0 > [tuck modulus dup 0 >] loop pop
- 27 15 15 . 0 > [tuck modulus dup 0 >] loop pop
- 27 15 15 0 . > [tuck modulus dup 0 >] loop pop
- 27 15 True . [tuck modulus dup 0 >] loop pop
- 27 15 True [tuck modulus dup 0 >] . loop pop
- 27 15 . tuck modulus dup 0 > [tuck modulus dup 0 >] loop pop
- 15 27 15 . modulus dup 0 > [tuck modulus dup 0 >] loop pop
- 15 12 . dup 0 > [tuck modulus dup 0 >] loop pop
- 15 12 12 . 0 > [tuck modulus dup 0 >] loop pop
- 15 12 12 0 . > [tuck modulus dup 0 >] loop pop
- 15 12 True . [tuck modulus dup 0 >] loop pop
- 15 12 True [tuck modulus dup 0 >] . loop pop
- 15 12 . tuck modulus dup 0 > [tuck modulus dup 0 >] loop pop
- 12 15 12 . modulus dup 0 > [tuck modulus dup 0 >] loop pop
- 12 3 . dup 0 > [tuck modulus dup 0 >] loop pop
- 12 3 3 . 0 > [tuck modulus dup 0 >] loop pop
- 12 3 3 0 . > [tuck modulus dup 0 >] loop pop
- 12 3 True . [tuck modulus dup 0 >] loop pop
- 12 3 True [tuck modulus dup 0 >] . loop pop
- 12 3 . tuck modulus dup 0 > [tuck modulus dup 0 >] loop pop
- 3 12 3 . modulus dup 0 > [tuck modulus dup 0 >] loop pop
- 3 0 . dup 0 > [tuck modulus dup 0 >] loop pop
- 3 0 0 . 0 > [tuck modulus dup 0 >] loop pop
- 3 0 0 0 . > [tuck modulus dup 0 >] loop pop
- 3 0 False . [tuck modulus dup 0 >] loop pop
- 3 0 False [tuck modulus dup 0 >] . loop pop
- 3 0 . pop
- 3 .
-
+ • 96 27 gcd
+ 96 • 27 gcd
+ 96 27 • gcd
+ 96 27 • 1 [tuck modulus dup 0 >] loop pop
+ 96 27 1 • [tuck modulus dup 0 >] loop pop
+ 96 27 1 [tuck modulus dup 0 >] • loop pop
+ 96 27 • tuck modulus dup 0 > [tuck modulus dup 0 >] loop pop
+ 27 96 27 • modulus dup 0 > [tuck modulus dup 0 >] loop pop
+ 27 15 • dup 0 > [tuck modulus dup 0 >] loop pop
+ 27 15 15 • 0 > [tuck modulus dup 0 >] loop pop
+ 27 15 15 0 • > [tuck modulus dup 0 >] loop pop
+ 27 15 True • [tuck modulus dup 0 >] loop pop
+ 27 15 True [tuck modulus dup 0 >] • loop pop
+ 27 15 • tuck modulus dup 0 > [tuck modulus dup 0 >] loop pop
+ 15 27 15 • modulus dup 0 > [tuck modulus dup 0 >] loop pop
+ 15 12 • dup 0 > [tuck modulus dup 0 >] loop pop
+ 15 12 12 • 0 > [tuck modulus dup 0 >] loop pop
+ 15 12 12 0 • > [tuck modulus dup 0 >] loop pop
+ 15 12 True • [tuck modulus dup 0 >] loop pop
+ 15 12 True [tuck modulus dup 0 >] • loop pop
+ 15 12 • tuck modulus dup 0 > [tuck modulus dup 0 >] loop pop
+ 12 15 12 • modulus dup 0 > [tuck modulus dup 0 >] loop pop
+ 12 3 • dup 0 > [tuck modulus dup 0 >] loop pop
+ 12 3 3 • 0 > [tuck modulus dup 0 >] loop pop
+ 12 3 3 0 • > [tuck modulus dup 0 >] loop pop
+ 12 3 True • [tuck modulus dup 0 >] loop pop
+ 12 3 True [tuck modulus dup 0 >] • loop pop
+ 12 3 • tuck modulus dup 0 > [tuck modulus dup 0 >] loop pop
+ 3 12 3 • modulus dup 0 > [tuck modulus dup 0 >] loop pop
+ 3 0 • dup 0 > [tuck modulus dup 0 >] loop pop
+ 3 0 0 • 0 > [tuck modulus dup 0 >] loop pop
+ 3 0 0 0 • > [tuck modulus dup 0 >] loop pop
+ 3 0 False • [tuck modulus dup 0 >] loop pop
+ 3 0 False [tuck modulus dup 0 >] • loop pop
+ 3 0 • pop
+ 3 •
diff --git a/docs/2._Library_Examples.html b/docs/2._Library_Examples.html
index 0f0e057..3a97419 100644
--- a/docs/2._Library_Examples.html
+++ b/docs/2._Library_Examples.html
@@ -13086,7 +13086,7 @@ div#notebook {
In [1]:
-from notebook_preamble import J, V
+from notebook_preamble import J, V
@@ -13114,7 +13114,7 @@ div#notebook {
In [2]:
-J('1 2 3 clear')
+J('1 2 3 clear')
@@ -13152,7 +13152,7 @@ div#notebook {
In [3]:
-J('1 2 3 dup')
+J('1 2 3 dup')
@@ -13183,7 +13183,7 @@ div#notebook {
In [4]:
-J('1 2 3 dupd')
+J('1 2 3 dupd')
@@ -13222,7 +13222,7 @@ div#notebook {
In [5]:
-J('1 2 3 enstacken')
+J('1 2 3 enstacken')
@@ -13261,7 +13261,7 @@ div#notebook {
In [6]:
-J('4 5 6 [3 2 1] unstack')
+J('4 5 6 [3 2 1] unstack')
@@ -13300,7 +13300,7 @@ div#notebook {
In [7]:
-J('1 2 3 stack')
+J('1 2 3 stack')
@@ -13341,7 +13341,7 @@ is on the top of both the list and the stack.
In [8]:
-J('1 2 3 [4 5 6] disenstacken')
+J('1 2 3 [4 5 6] disenstacken')
@@ -13379,7 +13379,7 @@ is on the top of both the list and the stack.
In [9]:
-J('1 2 3 pop')
+J('1 2 3 pop')
@@ -13410,7 +13410,7 @@ is on the top of both the list and the stack.
In [10]:
-J('1 2 3 popd')
+J('1 2 3 popd')
@@ -13441,7 +13441,7 @@ is on the top of both the list and the stack.
In [11]:
-J('1 2 3 popop')
+J('1 2 3 popop')
@@ -13480,7 +13480,7 @@ is on the top of both the list and the stack.
In [12]:
-J('1 2 3 roll<')
+J('1 2 3 roll<')
@@ -13511,7 +13511,7 @@ is on the top of both the list and the stack.
In [13]:
-J('1 2 3 roll>')
+J('1 2 3 roll>')
@@ -13549,7 +13549,7 @@ is on the top of both the list and the stack.
In [14]:
-J('1 2 3 swap')
+J('1 2 3 swap')
@@ -13587,7 +13587,7 @@ is on the top of both the list and the stack.
In [15]:
-J('1 2 3 tuck')
+J('1 2 3 tuck')
@@ -13618,7 +13618,7 @@ is on the top of both the list and the stack.
In [16]:
-J('1 2 3 over')
+J('1 2 3 over')
@@ -13656,7 +13656,7 @@ is on the top of both the list and the stack.
In [17]:
-J('1 2 3 unit')
+J('1 2 3 unit')
@@ -13687,7 +13687,7 @@ is on the top of both the list and the stack.
In [18]:
-J('1 2 3 quoted')
+J('1 2 3 quoted')
@@ -13718,7 +13718,7 @@ is on the top of both the list and the stack.
In [19]:
-J('1 [2] 3 unquoted')
+J('1 [2] 3 unquoted')
@@ -13749,7 +13749,7 @@ is on the top of both the list and the stack.
In [20]:
-V('1 [dup] 3 unquoted') # Unquoting evaluates. Be aware.
+V('1 [dup] 3 unquoted') # Unquoting evaluates. Be aware.
@@ -13766,16 +13766,16 @@ is on the top of both the list and the stack.
- . 1 [dup] 3 unquoted
- 1 . [dup] 3 unquoted
- 1 [dup] . 3 unquoted
- 1 [dup] 3 . unquoted
- 1 [dup] 3 . [i] dip
-1 [dup] 3 [i] . dip
- 1 [dup] . i 3
- 1 . dup 3
- 1 1 . 3
- 1 1 3 .
+ • 1 [dup] 3 unquoted
+ 1 • [dup] 3 unquoted
+ 1 [dup] • 3 unquoted
+ 1 [dup] 3 • unquoted
+ 1 [dup] 3 • [i] dip
+1 [dup] 3 [i] • dip
+ 1 [dup] • i 3
+ 1 • dup 3
+ 1 1 • 3
+ 1 1 3 •
@@ -13803,7 +13803,7 @@ is on the top of both the list and the stack.
In [21]:
-J('[1 2 3] [4 5 6] concat')
+J('[1 2 3] [4 5 6] concat')
@@ -13834,7 +13834,7 @@ is on the top of both the list and the stack.
In [22]:
-J('[1 2 3] [4 5 6] swoncat')
+J('[1 2 3] [4 5 6] swoncat')
@@ -13865,7 +13865,7 @@ is on the top of both the list and the stack.
In [23]:
-J('[1 2 3] [4 5 6] shunt')
+J('[1 2 3] [4 5 6] shunt')
@@ -13903,7 +13903,7 @@ is on the top of both the list and the stack.
In [24]:
-J('1 [2 3] cons')
+J('1 [2 3] cons')
@@ -13934,7 +13934,7 @@ is on the top of both the list and the stack.
In [25]:
-J('[2 3] 1 swons')
+J('[2 3] 1 swons')
@@ -13965,7 +13965,7 @@ is on the top of both the list and the stack.
In [26]:
-J('[1 2 3] uncons')
+J('[1 2 3] uncons')
@@ -14003,7 +14003,7 @@ is on the top of both the list and the stack.
In [27]:
-J('[1 2 3 4] first')
+J('[1 2 3 4] first')
@@ -14034,7 +14034,7 @@ is on the top of both the list and the stack.
In [28]:
-J('[1 2 3 4] second')
+J('[1 2 3 4] second')
@@ -14065,7 +14065,7 @@ is on the top of both the list and the stack.
In [29]:
-J('[1 2 3 4] third')
+J('[1 2 3 4] third')
@@ -14096,7 +14096,7 @@ is on the top of both the list and the stack.
In [30]:
-J('[1 2 3 4] rest')
+J('[1 2 3 4] rest')
@@ -14134,7 +14134,7 @@ is on the top of both the list and the stack.
In [31]:
-J('[[1] [2 [3] 4] [5 6]] flatten')
+J('[[1] [2 [3] 4] [5 6]] flatten')
@@ -14173,7 +14173,7 @@ is on the top of both the list and the stack.
In [32]:
-J('[10 11 12 13 14] 2 getitem')
+J('[10 11 12 13 14] 2 getitem')
@@ -14204,7 +14204,7 @@ is on the top of both the list and the stack.
In [33]:
-J('[1 2 3 4] 0 at')
+J('[1 2 3 4] 0 at')
@@ -14235,7 +14235,7 @@ is on the top of both the list and the stack.
In [34]:
-J('2 [1 2 3 4] of')
+J('2 [1 2 3 4] of')
@@ -14266,7 +14266,7 @@ is on the top of both the list and the stack.
In [35]:
-J('[1 2 3 4] 2 drop')
+J('[1 2 3 4] 2 drop')
@@ -14297,7 +14297,7 @@ is on the top of both the list and the stack.
In [36]:
-J('[1 2 3 4] 2 take') # reverses the order
+J('[1 2 3 4] 2 take') # reverses the order
@@ -14343,7 +14343,7 @@ is on the top of both the list and the stack.
In [37]:
-J('[1 2 3 1 4] 1 remove')
+J('[1 2 3 1 4] 1 remove')
@@ -14381,7 +14381,7 @@ is on the top of both the list and the stack.
In [38]:
-J('[1 2 3 4] reverse')
+J('[1 2 3 4] reverse')
@@ -14419,7 +14419,7 @@ is on the top of both the list and the stack.
In [39]:
-J('[1 1 1 1] size')
+J('[1 1 1 1] size')
@@ -14458,7 +14458,7 @@ is on the top of both the list and the stack.
In [40]:
-J('1 2 3 [4 5 6] swaack')
+J('1 2 3 [4 5 6] swaack')
@@ -14496,7 +14496,7 @@ is on the top of both the list and the stack.
In [41]:
-J('23 9 1 choice')
+J('23 9 1 choice')
@@ -14527,7 +14527,7 @@ is on the top of both the list and the stack.
In [42]:
-J('23 9 0 choice')
+J('23 9 0 choice')
@@ -14558,7 +14558,7 @@ is on the top of both the list and the stack.
In [43]:
-J('[23 9 7] 1 select') # select is basically getitem, should retire it?
+J('[23 9 7] 1 select') # select is basically getitem, should retire it?
@@ -14589,7 +14589,7 @@ is on the top of both the list and the stack.
In [44]:
-J('[23 9 7] 0 select')
+J('[23 9 7] 0 select')
@@ -14627,7 +14627,7 @@ is on the top of both the list and the stack.
In [45]:
-J('[1 2 3] [6 5 4] zip')
+J('[1 2 3] [6 5 4] zip')
@@ -14658,7 +14658,7 @@ is on the top of both the list and the stack.
In [46]:
-J('[1 2 3] [6 5 4] zip [sum] map')
+J('[1 2 3] [6 5 4] zip [sum] map')
@@ -14703,7 +14703,7 @@ is on the top of both the list and the stack.
In [47]:
-J('23 9 +')
+J('23 9 +')
@@ -14741,7 +14741,7 @@ is on the top of both the list and the stack.
In [48]:
-J('23 9 -')
+J('23 9 -')
@@ -14779,7 +14779,7 @@ is on the top of both the list and the stack.
In [49]:
-J('23 9 *')
+J('23 9 *')
@@ -14817,7 +14817,7 @@ is on the top of both the list and the stack.
In [50]:
-J('23 9 /')
+J('23 9 /')
@@ -14848,7 +14848,7 @@ is on the top of both the list and the stack.
In [51]:
-J('23 -9 truediv')
+J('23 -9 truediv')
@@ -14879,7 +14879,7 @@ is on the top of both the list and the stack.
In [52]:
-J('23 9 div')
+J('23 9 div')
@@ -14910,7 +14910,7 @@ is on the top of both the list and the stack.
In [53]:
-J('23 9 floordiv')
+J('23 9 floordiv')
@@ -14941,7 +14941,7 @@ is on the top of both the list and the stack.
In [54]:
-J('23 -9 div')
+J('23 -9 div')
@@ -14972,7 +14972,7 @@ is on the top of both the list and the stack.
In [55]:
-J('23 -9 floordiv')
+J('23 -9 floordiv')
@@ -15010,7 +15010,7 @@ is on the top of both the list and the stack.
In [56]:
-J('23 9 %')
+J('23 9 %')
@@ -15048,7 +15048,7 @@ is on the top of both the list and the stack.
In [57]:
-J('23 neg -5 neg')
+J('23 neg -5 neg')
@@ -15086,7 +15086,7 @@ is on the top of both the list and the stack.
In [58]:
-J('2 10 pow')
+J('2 10 pow')
@@ -15124,7 +15124,7 @@ is on the top of both the list and the stack.
In [59]:
-J('23 sqr')
+J('23 sqr')
@@ -15155,7 +15155,7 @@ is on the top of both the list and the stack.
In [60]:
-J('23 sqrt')
+J('23 sqrt')
@@ -15193,7 +15193,7 @@ is on the top of both the list and the stack.
In [61]:
-J('1 ++')
+J('1 ++')
@@ -15224,7 +15224,7 @@ is on the top of both the list and the stack.
In [62]:
-J('1 --')
+J('1 --')
@@ -15262,7 +15262,7 @@ is on the top of both the list and the stack.
In [63]:
-J('8 1 <<')
+J('8 1 <<')
@@ -15293,7 +15293,7 @@ is on the top of both the list and the stack.
In [64]:
-J('8 1 >>')
+J('8 1 >>')
@@ -15331,7 +15331,7 @@ is on the top of both the list and the stack.
In [65]:
-J('[1 2 3 5] average')
+J('[1 2 3 5] average')
@@ -15369,7 +15369,7 @@ is on the top of both the list and the stack.
In [66]:
-J('5 range')
+J('5 range')
@@ -15400,7 +15400,7 @@ is on the top of both the list and the stack.
In [67]:
-J('5 range_to_zero')
+J('5 range_to_zero')
@@ -15431,7 +15431,7 @@ is on the top of both the list and the stack.
In [68]:
-J('5 down_to_zero')
+J('5 down_to_zero')
@@ -15469,7 +15469,7 @@ is on the top of both the list and the stack.
In [69]:
-J('[1 2 3 5] product')
+J('[1 2 3 5] product')
@@ -15507,7 +15507,7 @@ is on the top of both the list and the stack.
In [70]:
-J('[1 2 3 5] sum')
+J('[1 2 3 5] sum')
@@ -15545,7 +15545,7 @@ is on the top of both the list and the stack.
In [71]:
-J('[1 2 3 5] min')
+J('[1 2 3 5] min')
@@ -15583,7 +15583,7 @@ is on the top of both the list and the stack.
In [72]:
-J('45 30 gcd')
+J('45 30 gcd')
@@ -15622,7 +15622,7 @@ is on the top of both the list and the stack.
In [73]:
-J('[45 30] least_fraction')
+J('[45 30] least_fraction')
@@ -15653,7 +15653,7 @@ is on the top of both the list and the stack.
In [74]:
-J('[23 12] least_fraction')
+J('[23 12] least_fraction')
@@ -15699,7 +15699,7 @@ is on the top of both the list and the stack.
In [75]:
-J('23 truthy')
+J('23 truthy')
@@ -15730,7 +15730,7 @@ is on the top of both the list and the stack.
In [76]:
-J('[] truthy') # Python semantics.
+J('[] truthy') # Python semantics.
@@ -15761,7 +15761,7 @@ is on the top of both the list and the stack.
In [77]:
-J('0 truthy')
+J('0 truthy')
@@ -15801,7 +15801,7 @@ is on the top of both the list and the stack.
In [78]:
-V('23 ?')
+V('23 ?')
@@ -15818,11 +15818,11 @@ is on the top of both the list and the stack.
- . 23 ?
- 23 . ?
- 23 . dup truthy
- 23 23 . truthy
-23 True .
+ • 23 ?
+ 23 • ?
+ 23 • dup truthy
+ 23 23 • truthy
+23 True •
@@ -15836,7 +15836,7 @@ is on the top of both the list and the stack.
In [79]:
-J('[] ?')
+J('[] ?')
@@ -15867,7 +15867,7 @@ is on the top of both the list and the stack.
In [80]:
-J('0 ?')
+J('0 ?')
@@ -15905,7 +15905,7 @@ is on the top of both the list and the stack.
In [81]:
-J('23 9 &')
+J('23 9 &')
@@ -15943,7 +15943,7 @@ is on the top of both the list and the stack.
In [82]:
-J('23 9 !=')
+J('23 9 !=')
@@ -15998,7 +15998,7 @@ is on the top of both the list and the stack.
In [83]:
-J('1 1 ^')
+J('1 1 ^')
@@ -16029,7 +16029,7 @@ is on the top of both the list and the stack.
In [84]:
-J('1 0 ^')
+J('1 0 ^')
@@ -16074,7 +16074,7 @@ is on the top of both the list and the stack.
In [85]:
-J('[help] help')
+J('[help] help')
@@ -16119,7 +16119,7 @@ Accepts a quoted symbol on the top of the stack and prints its docs.
In [86]:
-J('[parse] help')
+J('[parse] help')
@@ -16157,7 +16157,7 @@ Parse the string on the stack to a Joy expression.
In [87]:
-J('1 "2 [3] dup" parse')
+J('1 "2 [3] dup" parse')
@@ -16196,7 +16196,7 @@ Parse the string on the stack to a Joy expression.
In [88]:
-J('[1 2 dup + +] run')
+J('[1 2 dup + +] run')
@@ -16241,7 +16241,7 @@ Parse the string on the stack to a Joy expression.
In [89]:
-J('[app1] help')
+J('[app1] help')
@@ -16266,9 +16266,9 @@ the program and replace the two args with the first result of the
program.
::
- ... x [Q] . app1
- -----------------------------------
- ... [x ...] [Q] . infra first
+ ... x [Q] . app1
+ -----------------------------------
+ ... [x ...] [Q] . infra first
---- end (app1)
@@ -16286,7 +16286,7 @@ program.
In [90]:
-J('10 4 [sqr *] app1')
+J('10 4 [sqr *] app1')
@@ -16317,7 +16317,7 @@ program.
In [91]:
-J('10 3 4 [sqr *] app2')
+J('10 3 4 [sqr *] app2')
@@ -16348,7 +16348,7 @@ program.
In [92]:
-J('[app2] help')
+J('[app2] help')
@@ -16371,10 +16371,10 @@ program.
Like app1 with two items.
::
- ... y x [Q] . app2
- -----------------------------------
- ... [y ...] [Q] . infra first
- [x ...] [Q] infra first
+ ... y x [Q] . app2
+ -----------------------------------
+ ... [y ...] [Q] . infra first
+ [x ...] [Q] infra first
---- end (app2)
@@ -16392,7 +16392,7 @@ Like app1 with two items.
In [93]:
-J('10 2 3 4 [sqr *] app3')
+J('10 2 3 4 [sqr *] app3')
@@ -16440,7 +16440,7 @@ Like app1 with two items.
In [94]:
-J('3 [0 <=] [1 - dup] anamorphism')
+J('3 [0 <=] [1 - dup] anamorphism')
@@ -16478,7 +16478,7 @@ Like app1 with two items.
In [95]:
-J('3 4 1 [+] [*] branch')
+J('3 4 1 [+] [*] branch')
@@ -16509,7 +16509,7 @@ Like app1 with two items.
In [96]:
-J('3 4 0 [+] [*] branch')
+J('3 4 0 [+] [*] branch')
@@ -16559,7 +16559,7 @@ results P(X) and Q(X)."
In [97]:
-J('10 2 [+] [-] cleave')
+J('10 2 [+] [-] cleave')
@@ -16597,7 +16597,7 @@ results P(X) and Q(X)."
In [98]:
-J('1 2 3 4 5 [+] dip')
+J('1 2 3 4 5 [+] dip')
@@ -16628,7 +16628,7 @@ results P(X) and Q(X)."
In [99]:
-J('1 2 3 4 5 [+] dipd')
+J('1 2 3 4 5 [+] dipd')
@@ -16659,7 +16659,7 @@ results P(X) and Q(X)."
In [100]:
-J('1 2 3 4 5 [+] dipdd')
+J('1 2 3 4 5 [+] dipdd')
@@ -16700,7 +16700,7 @@ results P(X) and Q(X)."
In [101]:
-V('23 [++] dupdip *') # N(N + 1)
+