Rebuild docs with Python 3 and Sphinx 3.0.2.
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
# Joypy
|
||||
|
||||
## Joy in Python
|
||||
|
|
@ -52,58 +51,6 @@ import 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*.
|
||||
|
||||
|
|
@ -113,24 +60,10 @@ 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:
|
||||
|
||||
|
||||
|
|
@ -144,10 +77,6 @@ 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)*.
|
||||
|
||||
|
|
@ -164,40 +93,6 @@ import 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.
|
||||
|
||||
|
|
@ -341,7 +236,7 @@ import joy.library
|
|||
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 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 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 •
|
||||
|
||||
|
||||
Many of the functions are defined in Python, like `dip`:
|
||||
|
|
@ -379,42 +274,43 @@ Some functions are defined in equations in terms of other functions. When the i
|
|||
print joy.library.definitions
|
||||
```
|
||||
|
||||
ii == [dip] dupdip i
|
||||
of == swap at
|
||||
product == 1 swap [*] step
|
||||
flatten == [] swap [concat] step
|
||||
quoted == [unit] dip
|
||||
unquoted == [i] dip
|
||||
enstacken == stack [clear] dip
|
||||
? == dup truthy
|
||||
disenstacken == ? [uncons ?] loop pop
|
||||
dinfrirst == dip infra first
|
||||
nullary == [stack] dinfrirst
|
||||
unary == nullary popd
|
||||
binary == nullary [popop] dip
|
||||
ternary == unary [popop] dip
|
||||
pam == [i] map
|
||||
run == [] swap infra
|
||||
sqr == dup mul
|
||||
size == 0 swap [pop ++] step
|
||||
fork == [i] app2
|
||||
cleave == fork [popd] dip
|
||||
average == [sum 1.0 *] [size] cleave /
|
||||
gcd == 1 [tuck modulus dup 0 >] loop pop
|
||||
least_fraction == dup [gcd] infra [div] concat map
|
||||
*fraction == [uncons] dip uncons [swap] dip concat [*] infra [*] dip cons
|
||||
*fraction0 == concat [[swap] dip * [*] dip] infra
|
||||
down_to_zero == [0 >] [dup --] while
|
||||
range_to_zero == unit [down_to_zero] infra
|
||||
anamorphism == [pop []] swap [dip swons] genrec
|
||||
range == [0 <=] [1 - dup] anamorphism
|
||||
while == swap [nullary] cons dup dipd concat loop
|
||||
dupdipd == dup dipd
|
||||
primrec == [i] genrec
|
||||
step_zero == 0 roll> step
|
||||
average == [sum 1.0 *] [size] cleave /
|
||||
binary == nullary [popop] dip
|
||||
cleave == fork [popd] dip
|
||||
codireco == cons dip rest cons
|
||||
make_generator == [codireco] ccons
|
||||
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
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
Joypy
|
||||
=====
|
||||
|
||||
|
|
@ -74,61 +73,6 @@ tuples.
|
|||
|
||||
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.
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
|
@ -139,28 +83,10 @@ versa*.
|
|||
|
||||
joy.utils.stack.list_to_stack([1, 2, 3])
|
||||
|
||||
|
||||
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
(1, (2, (3, ())))
|
||||
|
||||
|
||||
|
||||
.. code:: ipython2
|
||||
|
||||
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
|
||||
|
|
@ -173,13 +99,6 @@ This requires reversing the sequence (or iterating backwards) otherwise:
|
|||
print stack
|
||||
print list(joy.utils.stack.iter_stack(stack))
|
||||
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
(3, (2, (1, ())))
|
||||
[3, 2, 1]
|
||||
|
||||
|
||||
Purely Functional Datastructures.
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
|
@ -211,43 +130,6 @@ command.)
|
|||
|
||||
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
|
||||
~~~~~~~~~~~~~
|
||||
|
||||
|
|
@ -431,7 +313,7 @@ provide control-flow and higher-order operations.
|
|||
|
||||
.. 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 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 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 •
|
||||
|
||||
|
||||
Many of the functions are defined in Python, like ``dip``:
|
||||
|
|
@ -476,42 +358,43 @@ continuation) and returns control to the interpreter.
|
|||
|
||||
.. parsed-literal::
|
||||
|
||||
ii == [dip] dupdip i
|
||||
of == swap at
|
||||
product == 1 swap [*] step
|
||||
flatten == [] swap [concat] step
|
||||
quoted == [unit] dip
|
||||
unquoted == [i] dip
|
||||
enstacken == stack [clear] dip
|
||||
? == dup truthy
|
||||
disenstacken == ? [uncons ?] loop pop
|
||||
dinfrirst == dip infra first
|
||||
nullary == [stack] dinfrirst
|
||||
unary == nullary popd
|
||||
binary == nullary [popop] dip
|
||||
ternary == unary [popop] dip
|
||||
pam == [i] map
|
||||
run == [] swap infra
|
||||
sqr == dup mul
|
||||
size == 0 swap [pop ++] step
|
||||
fork == [i] app2
|
||||
cleave == fork [popd] dip
|
||||
average == [sum 1.0 *] [size] cleave /
|
||||
gcd == 1 [tuck modulus dup 0 >] loop pop
|
||||
least_fraction == dup [gcd] infra [div] concat map
|
||||
*fraction == [uncons] dip uncons [swap] dip concat [*] infra [*] dip cons
|
||||
*fraction0 == concat [[swap] dip * [*] dip] infra
|
||||
down_to_zero == [0 >] [dup --] while
|
||||
range_to_zero == unit [down_to_zero] infra
|
||||
anamorphism == [pop []] swap [dip swons] genrec
|
||||
range == [0 <=] [1 - dup] anamorphism
|
||||
while == swap [nullary] cons dup dipd concat loop
|
||||
dupdipd == dup dipd
|
||||
primrec == [i] genrec
|
||||
step_zero == 0 roll> step
|
||||
average == [sum 1.0 *] [size] cleave /
|
||||
binary == nullary [popop] dip
|
||||
cleave == fork [popd] dip
|
||||
codireco == cons dip rest cons
|
||||
make_generator == [codireco] ccons
|
||||
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
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
### Preamble
|
||||
|
||||
First, import what we need.
|
||||
|
|
@ -135,3 +134,8 @@ V('96 27 gcd')
|
|||
3 0 . pop
|
||||
3 .
|
||||
|
||||
|
||||
|
||||
```python
|
||||
|
||||
```
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
Preamble
|
||||
~~~~~~~~
|
||||
|
||||
|
|
@ -152,3 +151,4 @@ Here's a longer trace.
|
|||
3 0 . pop
|
||||
3 .
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
# [Project Euler, first problem: "Multiples of 3 and 5"](https://projecteuler.net/problem=1)
|
||||
|
||||
If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23.
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
`Project Euler, first problem: "Multiples of 3 and 5" <https://projecteuler.net/problem=1>`__
|
||||
=============================================================================================
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
# Advent of Code 2017
|
||||
|
||||
## December 1st
|
||||
|
|
@ -158,6 +157,11 @@ J('[9 1 2 1 2 1 2 9] AoC2017.1')
|
|||
|
||||
AoC2017.1 == pair_up total_matches
|
||||
|
||||
|
||||
```python
|
||||
|
||||
```
|
||||
|
||||
Now the paired digit is "halfway" round.
|
||||
|
||||
[a b c d] dup size 2 / [drop] [take reverse] cleave concat zip
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
Advent of Code 2017
|
||||
===================
|
||||
|
||||
|
|
@ -203,6 +202,7 @@ Now we can define our main program and evaluate it on the examples.
|
|||
|
||||
AoC2017.1 == pair_up total_matches
|
||||
|
||||
|
||||
Now the paired digit is "halfway" round.
|
||||
|
||||
::
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
# Advent of Code 2017
|
||||
|
||||
## December 2nd
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
Advent of Code 2017
|
||||
===================
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
# Advent of Code 2017
|
||||
|
||||
## December 3rd
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
Advent of Code 2017
|
||||
===================
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
# Advent of Code 2017
|
||||
|
||||
## December 4th
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
Advent of Code 2017
|
||||
===================
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
# Advent of Code 2017
|
||||
|
||||
## December 5th
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
Advent of Code 2017
|
||||
===================
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
# Advent of Code 2017
|
||||
|
||||
## December 6th
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
Advent of Code 2017
|
||||
===================
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
|
||||
|
||||
```python
|
||||
from notebook_preamble import D, J, V, define
|
||||
```
|
||||
|
|
@ -418,6 +416,11 @@ V('[a b c d] 1 2 [f] Ee')
|
|||
[a 1 c d] .
|
||||
|
||||
|
||||
|
||||
```python
|
||||
|
||||
```
|
||||
|
||||
## Working with Yang Functions
|
||||
|
||||
Consider the compiled code of `dup`:
|
||||
|
|
@ -457,6 +460,16 @@ def sqr(stack):
|
|||
|
||||
```
|
||||
|
||||
|
||||
```python
|
||||
|
||||
```
|
||||
|
||||
|
||||
```python
|
||||
|
||||
```
|
||||
|
||||
How about...
|
||||
|
||||
|
||||
|
|
@ -491,6 +504,11 @@ def foo(stack):
|
|||
```
|
||||
|
||||
|
||||
```python
|
||||
|
||||
```
|
||||
|
||||
|
||||
```python
|
||||
stack_effects = infer_string('tuck')
|
||||
for fi, fo in stack_effects:
|
||||
|
|
@ -500,6 +518,11 @@ for fi, fo in stack_effects:
|
|||
(a2 a1 -- a1 a2 a1)
|
||||
|
||||
|
||||
|
||||
```python
|
||||
|
||||
```
|
||||
|
||||
## Compiling Yin~Yang Functions
|
||||
|
||||
First, we need a source of Python identifiers. I'm going to reuse `Symbol` class for this.
|
||||
|
|
@ -722,3 +745,23 @@ print compile_yinyang('to_the_fifth_power', e)
|
|||
return stack
|
||||
|
||||
|
||||
|
||||
|
||||
```python
|
||||
|
||||
```
|
||||
|
||||
|
||||
```python
|
||||
|
||||
```
|
||||
|
||||
|
||||
```python
|
||||
|
||||
```
|
||||
|
||||
|
||||
```python
|
||||
|
||||
```
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
.. code:: ipython2
|
||||
|
||||
from notebook_preamble import D, J, V, define
|
||||
|
|
@ -468,6 +467,7 @@ Compare:
|
|||
[a 1 c d] .
|
||||
|
||||
|
||||
|
||||
Working with Yang Functions
|
||||
---------------------------
|
||||
|
||||
|
|
@ -508,6 +508,8 @@ Then we would want something like this:
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
How about...
|
||||
|
||||
.. code:: ipython2
|
||||
|
|
@ -542,6 +544,7 @@ How about...
|
|||
|
||||
|
||||
|
||||
|
||||
.. code:: ipython2
|
||||
|
||||
stack_effects = infer_string('tuck')
|
||||
|
|
@ -554,6 +557,7 @@ How about...
|
|||
(a2 a1 -- a1 a2 a1)
|
||||
|
||||
|
||||
|
||||
Compiling Yin~Yang Functions
|
||||
----------------------------
|
||||
|
||||
|
|
@ -786,3 +790,7 @@ A few functions to try it with...
|
|||
return stack
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
# ~~Cerrect~~
|
||||
|
||||
# ~~Corroct~~
|
||||
|
|
@ -3631,6 +3630,21 @@ each_way(E, 'a0')
|
|||
|
||||
|
||||
|
||||
```python
|
||||
|
||||
```
|
||||
|
||||
|
||||
```python
|
||||
|
||||
```
|
||||
|
||||
|
||||
```python
|
||||
|
||||
```
|
||||
|
||||
|
||||
```python
|
||||
each_way(E, 'WRITE')
|
||||
```
|
||||
|
|
@ -3678,6 +3692,11 @@ simplify(each_way(E, 'WRITE'), with_mark='WRITE')
|
|||
|
||||
|
||||
|
||||
|
||||
```python
|
||||
|
||||
```
|
||||
|
||||
, Sorting Networks for routing, more basic functions.
|
||||
|
||||
Eventually: Orchestration with Joy.
|
||||
|
|
@ -4038,6 +4057,36 @@ But it's only about 1/9th of size of the previous version (which was 9261.)
|
|||
len(str(sum3))
|
||||
```
|
||||
|
||||
|
||||
```python
|
||||
|
||||
```
|
||||
|
||||
|
||||
```python
|
||||
|
||||
```
|
||||
|
||||
|
||||
```python
|
||||
|
||||
```
|
||||
|
||||
|
||||
```python
|
||||
|
||||
```
|
||||
|
||||
|
||||
```python
|
||||
|
||||
```
|
||||
|
||||
|
||||
```python
|
||||
|
||||
```
|
||||
|
||||
Let's simplify the first one manually just for fun:
|
||||
|
||||
(((((())) (())) ((()))))
|
||||
|
|
@ -4051,6 +4100,11 @@ Sure enough, it reduces to Mark after just a few applications of the rule `(())
|
|||
( )
|
||||
|
||||
|
||||
```python
|
||||
|
||||
```
|
||||
|
||||
|
||||
```python
|
||||
C = F((a, b))
|
||||
for form in (A, B, C):
|
||||
|
|
@ -4059,6 +4113,21 @@ for form in (A, B, C):
|
|||
```
|
||||
|
||||
|
||||
```python
|
||||
|
||||
```
|
||||
|
||||
|
||||
```python
|
||||
|
||||
```
|
||||
|
||||
|
||||
```python
|
||||
|
||||
```
|
||||
|
||||
|
||||
```python
|
||||
print A
|
||||
Aa = simplify(A, {a})
|
||||
|
|
@ -4091,6 +4160,26 @@ print a, c, Aac
|
|||
```
|
||||
|
||||
|
||||
```python
|
||||
|
||||
```
|
||||
|
||||
|
||||
```python
|
||||
|
||||
```
|
||||
|
||||
|
||||
```python
|
||||
|
||||
```
|
||||
|
||||
|
||||
```python
|
||||
|
||||
```
|
||||
|
||||
|
||||
```python
|
||||
from collections import Counter
|
||||
|
||||
|
|
@ -4149,6 +4238,11 @@ s7 = sum7
|
|||
```
|
||||
|
||||
|
||||
```python
|
||||
|
||||
```
|
||||
|
||||
|
||||
```python
|
||||
def super_simple(form):
|
||||
return to_fixed_point(form, simplify)
|
||||
|
|
@ -4172,9 +4266,44 @@ s7 = sum7
|
|||
```
|
||||
|
||||
|
||||
```python
|
||||
|
||||
```
|
||||
|
||||
|
||||
```python
|
||||
|
||||
```
|
||||
|
||||
|
||||
```python
|
||||
|
||||
```
|
||||
|
||||
|
||||
```python
|
||||
print ' '.join(name[:2] for name in sorted(R))
|
||||
for _ in range(20):
|
||||
print format_env(R), '=', b_register(R)
|
||||
R.update(cycle(P, R))
|
||||
```
|
||||
|
||||
|
||||
```python
|
||||
|
||||
```
|
||||
|
||||
|
||||
```python
|
||||
|
||||
```
|
||||
|
||||
|
||||
```python
|
||||
|
||||
```
|
||||
|
||||
|
||||
```python
|
||||
|
||||
```
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
[STRIKEOUT:Cerrect]
|
||||
===================
|
||||
|
||||
|
|
@ -3968,6 +3967,9 @@ on the -per-location-predicate.
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
.. code:: ipython2
|
||||
|
||||
each_way(E, 'WRITE')
|
||||
|
|
@ -4020,6 +4022,7 @@ on the -per-location-predicate.
|
|||
|
||||
|
||||
|
||||
|
||||
, Sorting Networks for routing, more basic functions.
|
||||
|
||||
Eventually: Orchestration with Joy.
|
||||
|
|
@ -4454,6 +4457,12 @@ But it's only about 1/9th of size of the previous version (which was
|
|||
|
||||
len(str(sum3))
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Let's simplify the first one manually just for fun:
|
||||
|
||||
::
|
||||
|
|
@ -4473,6 +4482,7 @@ original expression:
|
|||
(( ) )( )
|
||||
( )
|
||||
|
||||
|
||||
.. code:: ipython2
|
||||
|
||||
C = F((a, b))
|
||||
|
|
@ -4480,6 +4490,9 @@ original expression:
|
|||
arth = reify(form, env)
|
||||
print form, u'⟶', arth, u'⟶', value_of(arth)
|
||||
|
||||
|
||||
|
||||
|
||||
.. code:: ipython2
|
||||
|
||||
print A
|
||||
|
|
@ -4508,6 +4521,10 @@ original expression:
|
|||
Aac = simplify(Aa, {c})
|
||||
print a, c, Aac
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
.. code:: ipython2
|
||||
|
||||
from collections import Counter
|
||||
|
|
@ -4560,6 +4577,7 @@ Let's try using ``each_way()`` with the most common names in the form.
|
|||
# print len(str(s7))
|
||||
|
||||
|
||||
|
||||
.. code:: ipython2
|
||||
|
||||
def super_simple(form):
|
||||
|
|
@ -4580,9 +4598,16 @@ Let's try using ``each_way()`` with the most common names in the form.
|
|||
# print len(str(s7))
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
.. code:: ipython2
|
||||
|
||||
print ' '.join(name[:2] for name in sorted(R))
|
||||
for _ in range(20):
|
||||
print format_env(R), '=', b_register(R)
|
||||
R.update(cycle(P, R))
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
# ∂RE
|
||||
|
||||
## Brzozowski's Derivatives of Regular Expressions
|
||||
|
|
@ -814,3 +813,5 @@ hmm...
|
|||
|
||||
j = (01)*
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
∂RE
|
||||
===
|
||||
|
||||
|
|
@ -943,3 +942,5 @@ hmm...
|
|||
::
|
||||
|
||||
j = (01)*
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
# Using `x` to Generate Values
|
||||
|
||||
Cf. jp-reprod.html
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
Using ``x`` to Generate Values
|
||||
==============================
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
Cf. ["Bananas, Lenses, & Barbed Wire"](http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.41.125)
|
||||
|
||||
# [Hylomorphism](https://en.wikipedia.org/wiki/Hylomorphism_%28computer_science%29)
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
Cf. `"Bananas, Lenses, & Barbed
|
||||
Wire" <http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.41.125>`__
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
# [Newton's method](https://en.wikipedia.org/wiki/Newton%27s_method)
|
||||
Let's use the Newton-Raphson method for finding the root of an equation to write a function that can compute the square root of a number.
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
`Newton's method <https://en.wikipedia.org/wiki/Newton%27s_method>`__
|
||||
=====================================================================
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
# Treating Trees I: Ordered Binary Trees
|
||||
|
||||
Although any expression in Joy can be considered to describe a [tree](https://en.wikipedia.org/wiki/Tree_structure) with the quotes as compound nodes and the non-quote values as leaf nodes, in this page I want to talk about [ordered binary trees](https://en.wikipedia.org/wiki/Binary_search_tree) and how to make and use them.
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
Treating Trees I: Ordered Binary Trees
|
||||
======================================
|
||||
|
||||
|
|
|
|||
1641
docs/Quadratic.html
|
|
@ -1,5 +1,3 @@
|
|||
|
||||
|
||||
```python
|
||||
from notebook_preamble import J, V, define
|
||||
```
|
||||
|
|
@ -116,3 +114,8 @@ V('-5 1 4 quadratic')
|
|||
4.0 [1.0] . first
|
||||
4.0 1.0 .
|
||||
|
||||
|
||||
|
||||
```python
|
||||
|
||||
```
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
.. code:: ipython2
|
||||
|
||||
from notebook_preamble import J, V, define
|
||||
|
|
@ -156,3 +155,4 @@ get the results. This is pretty typical of Joy code.
|
|||
4.0 [1.0] . first
|
||||
4.0 1.0 .
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
|
||||
|
||||
```python
|
||||
from notebook_preamble import D, DefinitionWrapper, J, V, define
|
||||
```
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
.. code:: ipython2
|
||||
|
||||
from notebook_preamble import D, DefinitionWrapper, J, V, define
|
||||
|
|
|
|||
1612
docs/Replacing.html
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
# Replacing Functions in the Dictionary
|
||||
For now, there is no way to define new functions from within the Joy language. All functions (and the interpreter) all accept and return a dictionary parameter (in addition to the stack and expression) so that we can implement e.g. a function that adds new functions to the dictionary. However, there's no function that does that. Adding a new function to the dictionary is a meta-interpreter action, you have to do it in Python, not Joy.
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
Replacing Functions in the Dictionary
|
||||
=====================================
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
# The Four Fundamental Operations of Definite Action
|
||||
|
||||
All definite actions (computer program) can be defined by four fundamental patterns of combination:
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
The Four Fundamental Operations of Definite Action
|
||||
==================================================
|
||||
|
||||
|
|
|
|||
2214
docs/Trees.html
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
# Treating Trees
|
||||
Although any expression in Joy can be considered to describe a [tree](https://en.wikipedia.org/wiki/Tree_structure) with the quotes as compound nodes and the non-quote values as leaf nodes, in this page I want to talk about [ordered binary trees](https://en.wikipedia.org/wiki/Binary_search_tree) and how to make and use them.
|
||||
|
||||
|
|
@ -1540,7 +1539,7 @@ Let's reexamine:
|
|||
left BTree-iter-order key value F right BTree-iter-order
|
||||
|
||||
|
||||
[key value left right] disenstacken swap
|
||||
[key value left right] unstack swap
|
||||
key value left right swap
|
||||
key value right left
|
||||
|
||||
|
|
@ -1555,11 +1554,11 @@ Let's reexamine:
|
|||
|
||||
So:
|
||||
|
||||
R0 == disenstacken swap
|
||||
R0 == unstack swap
|
||||
R1 == [cons dipdd [F] dip] dupdip i
|
||||
|
||||
[key value left right] R0 [BTree-iter-order] R1
|
||||
[key value left right] disenstacken swap [BTree-iter-order] [cons dipdd [F] dip] dupdip i
|
||||
[key value left right] unstack swap [BTree-iter-order] [cons dipdd [F] dip] dupdip i
|
||||
key value right left [BTree-iter-order] [cons dipdd [F] dip] dupdip i
|
||||
|
||||
key value right left [BTree-iter-order] cons dipdd [F] dip [BTree-iter-order] i
|
||||
|
|
@ -1569,7 +1568,7 @@ So:
|
|||
left BTree-iter-order key value F right BTree-iter-order
|
||||
|
||||
|
||||
BTree-iter-order == [not] [pop] [disenstacken swap] [[cons dipdd [F] dip] dupdip i] genrec
|
||||
BTree-iter-order == [not] [pop] [unstack swap] [[cons dipdd [F] dip] dupdip i] genrec
|
||||
|
||||
#### Refactor `cons cons`
|
||||
cons2 == cons cons
|
||||
|
|
@ -1639,8 +1638,8 @@ For pre- and post-order we can use the `step` trick:
|
|||
|
||||
We worked out one scheme for ?in-order? traversal above, but maybe we can do better?
|
||||
|
||||
[key value left right] [F] [BTree-iter] [disenstacken] dipd
|
||||
[key value left right] disenstacken [F] [BTree-iter]
|
||||
[key value left right] [F] [BTree-iter] [unstack] dipd
|
||||
[key value left right] unstack [F] [BTree-iter]
|
||||
key value left right [F] [BTree-iter]
|
||||
|
||||
key value left right [F] [BTree-iter] R1.1
|
||||
|
|
@ -1651,8 +1650,8 @@ Hmm...
|
|||
key value left right [BTree-iter] [F] [BTree-iter]
|
||||
|
||||
|
||||
[key value left right] [F] [BTree-iter] [disenstacken [roll>] dip] dipd
|
||||
[key value left right] disenstacken [roll>] dip [F] [BTree-iter]
|
||||
[key value left right] [F] [BTree-iter] [unstack [roll>] dip] dipd
|
||||
[key value left right] unstack [roll>] dip [F] [BTree-iter]
|
||||
key value left right [roll>] dip [F] [BTree-iter]
|
||||
key value left roll> right [F] [BTree-iter]
|
||||
left key value right [F] [BTree-iter]
|
||||
|
|
@ -1674,3 +1673,63 @@ If I understand it correctly, the "Bananas..." paper talks about a way to build
|
|||
That's fine. Circular datastructures can't be made though.
|
||||
|
||||
|
||||
|
||||
|
||||
```python
|
||||
|
||||
```
|
||||
|
||||
|
||||
```python
|
||||
|
||||
```
|
||||
|
||||
|
||||
```python
|
||||
|
||||
```
|
||||
|
||||
|
||||
```python
|
||||
|
||||
```
|
||||
|
||||
|
||||
```python
|
||||
|
||||
```
|
||||
|
||||
|
||||
```python
|
||||
|
||||
```
|
||||
|
||||
|
||||
```python
|
||||
|
||||
```
|
||||
|
||||
|
||||
```python
|
||||
|
||||
```
|
||||
|
||||
|
||||
```python
|
||||
|
||||
```
|
||||
|
||||
|
||||
```python
|
||||
|
||||
```
|
||||
|
||||
|
||||
```python
|
||||
|
||||
```
|
||||
|
||||
|
||||
```python
|
||||
|
||||
```
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
Treating Trees
|
||||
==============
|
||||
|
||||
|
|
@ -2019,7 +2018,7 @@ Let's reexamine:
|
|||
left BTree-iter-order key value F right BTree-iter-order
|
||||
|
||||
|
||||
[key value left right] disenstacken swap
|
||||
[key value left right] unstack swap
|
||||
key value left right swap
|
||||
key value right left
|
||||
|
||||
|
|
@ -2036,11 +2035,11 @@ So:
|
|||
|
||||
::
|
||||
|
||||
R0 == disenstacken swap
|
||||
R0 == unstack swap
|
||||
R1 == [cons dipdd [F] dip] dupdip i
|
||||
|
||||
[key value left right] R0 [BTree-iter-order] R1
|
||||
[key value left right] disenstacken swap [BTree-iter-order] [cons dipdd [F] dip] dupdip i
|
||||
[key value left right] unstack swap [BTree-iter-order] [cons dipdd [F] dip] dupdip i
|
||||
key value right left [BTree-iter-order] [cons dipdd [F] dip] dupdip i
|
||||
|
||||
key value right left [BTree-iter-order] cons dipdd [F] dip [BTree-iter-order] i
|
||||
|
|
@ -2050,7 +2049,7 @@ So:
|
|||
left BTree-iter-order key value F right BTree-iter-order
|
||||
|
||||
|
||||
BTree-iter-order == [not] [pop] [disenstacken swap] [[cons dipdd [F] dip] dupdip i] genrec
|
||||
BTree-iter-order == [not] [pop] [unstack swap] [[cons dipdd [F] dip] dupdip i] genrec
|
||||
|
||||
Refactor ``cons cons``
|
||||
^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
@ -2166,8 +2165,8 @@ can do better?
|
|||
|
||||
::
|
||||
|
||||
[key value left right] [F] [BTree-iter] [disenstacken] dipd
|
||||
[key value left right] disenstacken [F] [BTree-iter]
|
||||
[key value left right] [F] [BTree-iter] [unstack] dipd
|
||||
[key value left right] unstack [F] [BTree-iter]
|
||||
key value left right [F] [BTree-iter]
|
||||
|
||||
key value left right [F] [BTree-iter] R1.1
|
||||
|
|
@ -2180,8 +2179,8 @@ Hmm...
|
|||
key value left right [BTree-iter] [F] [BTree-iter]
|
||||
|
||||
|
||||
[key value left right] [F] [BTree-iter] [disenstacken [roll>] dip] dipd
|
||||
[key value left right] disenstacken [roll>] dip [F] [BTree-iter]
|
||||
[key value left right] [F] [BTree-iter] [unstack [roll>] dip] dipd
|
||||
[key value left right] unstack [roll>] dip [F] [BTree-iter]
|
||||
key value left right [roll>] dip [F] [BTree-iter]
|
||||
key value left roll> right [F] [BTree-iter]
|
||||
left key value right [F] [BTree-iter]
|
||||
|
|
@ -2208,3 +2207,15 @@ because lookup happens at evaluation, not parsing. E.g.:
|
|||
B == ... A ...
|
||||
|
||||
That's fine. Circular datastructures can't be made though.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
1785
docs/Treestep.html
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
# Treating Trees II: `treestep`
|
||||
Let's consider a tree structure, similar to one described ["Why functional programming matters" by John Hughes](https://www.cs.kent.ac.uk/people/staff/dat/miranda/whyfp90.pdf), that consists of a node value followed by zero or more child trees. (The asterisk is meant to indicate the [Kleene star](https://en.wikipedia.org/wiki/Kleene_star).)
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
Treating Trees II: ``treestep``
|
||||
===============================
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
# Type Checking
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
Type Checking
|
||||
=============
|
||||
|
||||
|
|
|
|||
2499
docs/Types.html
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
# The Blissful Elegance of Typing Joy
|
||||
|
||||
This notebook presents a simple type inferencer for Joy code. It can infer the stack effect of most Joy expressions. It's built largely by means of existing ideas and research. (A great overview of the existing knowledge is a talk ["Type Inference in Stack-Based Programming Languages"](http://prl.ccs.neu.edu/blog/2017/03/10/type-inference-in-stack-based-programming-languages/) given by Rob Kleffner on or about 2017-03-10 as part of a course on the history of programming languages.)
|
||||
|
|
@ -1731,6 +1730,31 @@ print compile_('Q', Q)
|
|||
|
||||
|
||||
|
||||
```python
|
||||
|
||||
```
|
||||
|
||||
|
||||
```python
|
||||
|
||||
```
|
||||
|
||||
|
||||
```python
|
||||
|
||||
```
|
||||
|
||||
|
||||
```python
|
||||
|
||||
```
|
||||
|
||||
|
||||
```python
|
||||
|
||||
```
|
||||
|
||||
|
||||
```python
|
||||
unstack = (S[1], S[0]), S[1]
|
||||
enstacken = S[0], (S[0], S[1])
|
||||
|
|
@ -1780,6 +1804,11 @@ C(cons, unstack)
|
|||
|
||||
|
||||
|
||||
|
||||
```python
|
||||
|
||||
```
|
||||
|
||||
## Part VI: Multiple Stack Effects
|
||||
...
|
||||
|
||||
|
|
@ -2124,6 +2153,11 @@ def compose(f, g):
|
|||
```
|
||||
|
||||
|
||||
```python
|
||||
|
||||
```
|
||||
|
||||
|
||||
```python
|
||||
def meta_compose(F, G):
|
||||
for f, g in product(F, G):
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
The Blissful Elegance of Typing Joy
|
||||
===================================
|
||||
|
||||
|
|
@ -2049,6 +2048,11 @@ comments are now already in the form needed for the Python code:
|
|||
return (((a2, (a1, s1)), s2), ((a2, (a1, s1)), s2))
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
.. code:: ipython2
|
||||
|
||||
unstack = (S[1], S[0]), S[1]
|
||||
|
|
@ -2107,6 +2111,7 @@ comments are now already in the form needed for the Python code:
|
|||
|
||||
|
||||
|
||||
|
||||
Part VI: Multiple Stack Effects
|
||||
-------------------------------
|
||||
|
||||
|
|
@ -2495,6 +2500,7 @@ This function has to be modified to yield multiple results.
|
|||
yield update(result, (f_in, g_out))
|
||||
|
||||
|
||||
|
||||
.. code:: ipython2
|
||||
|
||||
def meta_compose(F, G):
|
||||
|
|
|
|||
1680
docs/Zipper.html
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
# Traversing Datastructures with Zippers
|
||||
This notebook is about using the "zipper" with joy datastructures. See the [Zipper wikipedia entry](https://en.wikipedia.org/wiki/Zipper_%28data_structure%29) or the original paper: ["FUNCTIONAL PEARL The Zipper" by Gérard Huet](https://www.st.cs.uni-saarland.de/edu/seminare/2005/advanced-fp/docs/huet-zipper.pdf)
|
||||
|
||||
|
|
@ -275,3 +274,8 @@ It's easy to read off (in reverse) the right sequence of "d" and "i" from the su
|
|||
|
||||
[ n [ n [ n n x ...
|
||||
i d i d i d d Bingo!
|
||||
|
||||
|
||||
```python
|
||||
|
||||
```
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
Traversing Datastructures with Zippers
|
||||
======================================
|
||||
|
||||
|
|
@ -351,3 +350,4 @@ from the subject datastructure:
|
|||
|
||||
[ n [ n [ n n x ...
|
||||
i d i d i d d Bingo!
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
|
||||
|
||||
```python
|
||||
from notebook_preamble import D, DefinitionWrapper, J, V, define
|
||||
```
|
||||
|
|
@ -234,3 +232,8 @@ Or:
|
|||
To limit `F` to working on pairs of terms from its domain.
|
||||
|
||||
|
||||
|
||||
|
||||
```python
|
||||
|
||||
```
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
.. code:: ipython2
|
||||
|
||||
from notebook_preamble import D, DefinitionWrapper, J, V, define
|
||||
|
|
@ -335,3 +334,4 @@ Or:
|
|||
a [b c] [F] step
|
||||
|
||||
To limit ``F`` to working on pairs of terms from its domain.
|
||||
|
||||
|
|
|
|||
|
|
@ -1,185 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
|
||||
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<!-- Generated by graphviz version 2.38.0 (20140413.2041)
|
||||
-->
|
||||
<!-- Title: finite_state_machine Pages: 1 -->
|
||||
<svg width="534pt" height="270pt"
|
||||
viewBox="0.00 0.00 534.00 270.00" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(4 266)">
|
||||
<title>finite_state_machine</title>
|
||||
<polygon fill="white" stroke="none" points="-4,4 -4,-266 530,-266 530,4 -4,4"/>
|
||||
<!-- i -->
|
||||
<g id="node1" class="node"><title>i</title>
|
||||
<ellipse fill="none" stroke="black" cx="338" cy="-146" rx="18" ry="18"/>
|
||||
<ellipse fill="none" stroke="black" cx="338" cy="-146" rx="22" ry="22"/>
|
||||
<text text-anchor="middle" x="338" y="-142.3" font-family="Times,serif" font-size="14.00">i</text>
|
||||
</g>
|
||||
<!-- i->i -->
|
||||
<g id="edge17" class="edge"><title>i->i</title>
|
||||
<path fill="none" stroke="black" d="M330.317,-166.991C329.369,-177.087 331.93,-186 338,-186 341.889,-186 344.337,-182.342 345.346,-177.059"/>
|
||||
<polygon fill="black" stroke="black" points="348.846,-177.102 345.683,-166.991 341.85,-176.868 348.846,-177.102"/>
|
||||
<text text-anchor="middle" x="338" y="-189.8" font-family="Times,serif" font-size="14.00">0</text>
|
||||
</g>
|
||||
<!-- j -->
|
||||
<g id="node10" class="node"><title>j</title>
|
||||
<ellipse fill="none" stroke="black" cx="421" cy="-136" rx="18" ry="18"/>
|
||||
<text text-anchor="middle" x="421" y="-132.3" font-family="Times,serif" font-size="14.00">j</text>
|
||||
</g>
|
||||
<!-- i->j -->
|
||||
<g id="edge18" class="edge"><title>i->j</title>
|
||||
<path fill="none" stroke="black" d="M357.466,-135.495C363.775,-132.451 371.008,-129.536 378,-128 383.213,-126.855 388.811,-126.984 394.167,-127.763"/>
|
||||
<polygon fill="black" stroke="black" points="393.487,-131.197 404.002,-129.894 394.97,-124.355 393.487,-131.197"/>
|
||||
<text text-anchor="middle" x="381.5" y="-131.8" font-family="Times,serif" font-size="14.00">1</text>
|
||||
</g>
|
||||
<!-- h -->
|
||||
<g id="node2" class="node"><title>h</title>
|
||||
<ellipse fill="none" stroke="black" cx="504" cy="-85" rx="18" ry="18"/>
|
||||
<ellipse fill="none" stroke="black" cx="504" cy="-85" rx="22" ry="22"/>
|
||||
<text text-anchor="middle" x="504" y="-81.3" font-family="Times,serif" font-size="14.00">h</text>
|
||||
</g>
|
||||
<!-- h->i -->
|
||||
<g id="edge15" class="edge"><title>h->i</title>
|
||||
<path fill="none" stroke="black" d="M481.868,-83.4025C461.033,-82.62 428.676,-83.5645 403,-94 387.267,-100.394 372.373,-112.028 360.918,-122.673"/>
|
||||
<polygon fill="black" stroke="black" points="358.306,-120.33 353.569,-129.807 363.182,-125.353 358.306,-120.33"/>
|
||||
<text text-anchor="middle" x="421" y="-97.8" font-family="Times,serif" font-size="14.00">0</text>
|
||||
</g>
|
||||
<!-- h->h -->
|
||||
<g id="edge16" class="edge"><title>h->h</title>
|
||||
<path fill="none" stroke="black" d="M496.317,-105.991C495.369,-116.087 497.93,-125 504,-125 507.889,-125 510.337,-121.342 511.346,-116.059"/>
|
||||
<polygon fill="black" stroke="black" points="514.846,-116.102 511.683,-105.991 507.85,-115.868 514.846,-116.102"/>
|
||||
<text text-anchor="middle" x="504" y="-128.8" font-family="Times,serif" font-size="14.00">1</text>
|
||||
</g>
|
||||
<!-- a -->
|
||||
<g id="node3" class="node"><title>a</title>
|
||||
<ellipse fill="none" stroke="black" cx="18" cy="-128" rx="18" ry="18"/>
|
||||
<text text-anchor="middle" x="18" y="-124.3" font-family="Times,serif" font-size="14.00">a</text>
|
||||
</g>
|
||||
<!-- b -->
|
||||
<g id="node4" class="node"><title>b</title>
|
||||
<ellipse fill="none" stroke="black" cx="255" cy="-113" rx="18" ry="18"/>
|
||||
<text text-anchor="middle" x="255" y="-109.3" font-family="Times,serif" font-size="14.00">b</text>
|
||||
</g>
|
||||
<!-- a->b -->
|
||||
<g id="edge1" class="edge"><title>a->b</title>
|
||||
<path fill="none" stroke="black" d="M36.2801,-126.897C76.7816,-124.312 178.091,-117.845 226.89,-114.73"/>
|
||||
<polygon fill="black" stroke="black" points="227.255,-118.214 237.011,-114.084 226.809,-111.229 227.255,-118.214"/>
|
||||
<text text-anchor="middle" x="136.5" y="-123.8" font-family="Times,serif" font-size="14.00">0</text>
|
||||
</g>
|
||||
<!-- c -->
|
||||
<g id="node5" class="node"><title>c</title>
|
||||
<ellipse fill="none" stroke="black" cx="97" cy="-155" rx="18" ry="18"/>
|
||||
<text text-anchor="middle" x="97" y="-151.3" font-family="Times,serif" font-size="14.00">c</text>
|
||||
</g>
|
||||
<!-- a->c -->
|
||||
<g id="edge2" class="edge"><title>a->c</title>
|
||||
<path fill="none" stroke="black" d="M35.3297,-133.726C45.4364,-137.27 58.635,-141.898 70.1398,-145.932"/>
|
||||
<polygon fill="black" stroke="black" points="69.099,-149.276 79.6938,-149.282 71.4153,-142.67 69.099,-149.276"/>
|
||||
<text text-anchor="middle" x="57.5" y="-145.8" font-family="Times,serif" font-size="14.00">1</text>
|
||||
</g>
|
||||
<!-- b->b -->
|
||||
<g id="edge3" class="edge"><title>b->b</title>
|
||||
<path fill="none" stroke="black" d="M248.266,-130.037C246.892,-139.858 249.137,-149 255,-149 258.665,-149 260.916,-145.429 261.753,-140.353"/>
|
||||
<polygon fill="black" stroke="black" points="265.252,-140.031 261.734,-130.037 258.252,-140.044 265.252,-140.031"/>
|
||||
<text text-anchor="middle" x="255" y="-152.8" font-family="Times,serif" font-size="14.00">0</text>
|
||||
</g>
|
||||
<!-- d -->
|
||||
<g id="node6" class="node"><title>d</title>
|
||||
<ellipse fill="none" stroke="black" cx="338" cy="-79" rx="18" ry="18"/>
|
||||
<text text-anchor="middle" x="338" y="-75.3" font-family="Times,serif" font-size="14.00">d</text>
|
||||
</g>
|
||||
<!-- b->d -->
|
||||
<g id="edge4" class="edge"><title>b->d</title>
|
||||
<path fill="none" stroke="black" d="M272.003,-106.283C283.319,-101.533 298.722,-95.0674 311.693,-89.6227"/>
|
||||
<polygon fill="black" stroke="black" points="313.164,-92.801 321.03,-85.7034 310.455,-86.3466 313.164,-92.801"/>
|
||||
<text text-anchor="middle" x="294.5" y="-101.8" font-family="Times,serif" font-size="14.00">1</text>
|
||||
</g>
|
||||
<!-- c->b -->
|
||||
<g id="edge5" class="edge"><title>c->b</title>
|
||||
<path fill="none" stroke="black" d="M114.862,-150.653C138.269,-144.593 181.917,-133.2 219,-123 221.799,-122.23 224.721,-121.414 227.631,-120.594"/>
|
||||
<polygon fill="black" stroke="black" points="228.623,-123.951 237.284,-117.849 226.708,-117.218 228.623,-123.951"/>
|
||||
<text text-anchor="middle" x="176" y="-142.8" font-family="Times,serif" font-size="14.00">0</text>
|
||||
</g>
|
||||
<!-- e -->
|
||||
<g id="node7" class="node"><title>e</title>
|
||||
<ellipse fill="none" stroke="black" cx="176" cy="-206" rx="18" ry="18"/>
|
||||
<text text-anchor="middle" x="176" y="-202.3" font-family="Times,serif" font-size="14.00">e</text>
|
||||
</g>
|
||||
<!-- c->e -->
|
||||
<g id="edge6" class="edge"><title>c->e</title>
|
||||
<path fill="none" stroke="black" d="M112.483,-164.593C123.668,-172.001 139.356,-182.392 152.219,-190.911"/>
|
||||
<polygon fill="black" stroke="black" points="150.312,-193.846 160.582,-196.45 154.177,-188.01 150.312,-193.846"/>
|
||||
<text text-anchor="middle" x="136.5" y="-185.8" font-family="Times,serif" font-size="14.00">1</text>
|
||||
</g>
|
||||
<!-- d->b -->
|
||||
<g id="edge7" class="edge"><title>d->b</title>
|
||||
<path fill="none" stroke="black" d="M320.205,-74.8763C311.208,-73.4911 300.131,-73.1424 291,-77 284.094,-79.9175 277.879,-84.9376 272.669,-90.3183"/>
|
||||
<polygon fill="black" stroke="black" points="269.694,-88.4067 265.791,-98.2568 274.985,-92.9902 269.694,-88.4067"/>
|
||||
<text text-anchor="middle" x="294.5" y="-80.8" font-family="Times,serif" font-size="14.00">0</text>
|
||||
</g>
|
||||
<!-- f -->
|
||||
<g id="node8" class="node"><title>f</title>
|
||||
<ellipse fill="none" stroke="black" cx="176" cy="-46" rx="18" ry="18"/>
|
||||
<text text-anchor="middle" x="176" y="-42.3" font-family="Times,serif" font-size="14.00">f</text>
|
||||
</g>
|
||||
<!-- d->f -->
|
||||
<g id="edge8" class="edge"><title>d->f</title>
|
||||
<path fill="none" stroke="black" d="M319.923,-75.478C292.098,-69.7389 236.768,-58.3271 203.708,-51.5086"/>
|
||||
<polygon fill="black" stroke="black" points="204.321,-48.0614 193.82,-49.4692 202.907,-54.9171 204.321,-48.0614"/>
|
||||
<text text-anchor="middle" x="255" y="-69.8" font-family="Times,serif" font-size="14.00">1</text>
|
||||
</g>
|
||||
<!-- e->b -->
|
||||
<g id="edge9" class="edge"><title>e->b</title>
|
||||
<path fill="none" stroke="black" d="M190.241,-194.796C198.908,-187.136 210.212,-176.503 219,-166 226.507,-157.028 233.803,-146.389 239.774,-137.007"/>
|
||||
<polygon fill="black" stroke="black" points="242.759,-138.834 245.056,-128.491 236.81,-135.144 242.759,-138.834"/>
|
||||
<text text-anchor="middle" x="215.5" y="-176.8" font-family="Times,serif" font-size="14.00">0</text>
|
||||
</g>
|
||||
<!-- g -->
|
||||
<g id="node9" class="node"><title>g</title>
|
||||
<ellipse fill="none" stroke="black" cx="255" cy="-211" rx="18" ry="18"/>
|
||||
<text text-anchor="middle" x="255" y="-207.3" font-family="Times,serif" font-size="14.00">g</text>
|
||||
</g>
|
||||
<!-- e->g -->
|
||||
<g id="edge10" class="edge"><title>e->g</title>
|
||||
<path fill="none" stroke="black" d="M194.089,-207.11C203.659,-207.731 215.817,-208.521 226.677,-209.226"/>
|
||||
<polygon fill="black" stroke="black" points="226.753,-212.738 236.959,-209.893 227.207,-205.753 226.753,-212.738"/>
|
||||
<text text-anchor="middle" x="215.5" y="-211.8" font-family="Times,serif" font-size="14.00">1</text>
|
||||
</g>
|
||||
<!-- f->h -->
|
||||
<g id="edge12" class="edge"><title>f->h</title>
|
||||
<path fill="none" stroke="black" d="M189.02,-33.1864C203.151,-19.5754 227.995,-0 254,-0 254,-0 254,-0 422,-0 453.632,-0 476.677,-31.2311 489.924,-55.8314"/>
|
||||
<polygon fill="black" stroke="black" points="486.862,-57.5325 494.518,-64.8562 493.1,-54.3566 486.862,-57.5325"/>
|
||||
<text text-anchor="middle" x="338" y="-3.8" font-family="Times,serif" font-size="14.00">1</text>
|
||||
</g>
|
||||
<!-- f->b -->
|
||||
<g id="edge11" class="edge"><title>f->b</title>
|
||||
<path fill="none" stroke="black" d="M190.834,-56.7689C199.13,-63.3319 209.817,-71.9742 219,-80 224.034,-84.4001 229.343,-89.2757 234.262,-93.899"/>
|
||||
<polygon fill="black" stroke="black" points="231.917,-96.4985 241.576,-100.852 236.74,-91.4252 231.917,-96.4985"/>
|
||||
<text text-anchor="middle" x="215.5" y="-83.8" font-family="Times,serif" font-size="14.00">0</text>
|
||||
</g>
|
||||
<!-- g->i -->
|
||||
<g id="edge13" class="edge"><title>g->i</title>
|
||||
<path fill="none" stroke="black" d="M269.741,-199.974C281.437,-190.587 298.524,-176.876 312.548,-165.622"/>
|
||||
<polygon fill="black" stroke="black" points="314.778,-168.32 320.387,-159.331 310.397,-162.86 314.778,-168.32"/>
|
||||
<text text-anchor="middle" x="294.5" y="-185.8" font-family="Times,serif" font-size="14.00">0</text>
|
||||
</g>
|
||||
<!-- g->g -->
|
||||
<g id="edge14" class="edge"><title>g->g</title>
|
||||
<path fill="none" stroke="black" d="M248.266,-228.037C246.892,-237.858 249.137,-247 255,-247 258.665,-247 260.916,-243.429 261.753,-238.353"/>
|
||||
<polygon fill="black" stroke="black" points="265.252,-238.031 261.734,-228.037 258.252,-238.044 265.252,-238.031"/>
|
||||
<text text-anchor="middle" x="255" y="-250.8" font-family="Times,serif" font-size="14.00">1</text>
|
||||
</g>
|
||||
<!-- j->i -->
|
||||
<g id="edge19" class="edge"><title>j->i</title>
|
||||
<path fill="none" stroke="black" d="M403.34,-139.8C397.561,-140.993 391.021,-142.205 385,-143 380.321,-143.618 375.357,-144.11 370.488,-144.502"/>
|
||||
<polygon fill="black" stroke="black" points="369.864,-141.036 360.126,-145.209 370.341,-148.02 369.864,-141.036"/>
|
||||
<text text-anchor="middle" x="381.5" y="-146.8" font-family="Times,serif" font-size="14.00">0</text>
|
||||
</g>
|
||||
<!-- j->h -->
|
||||
<g id="edge20" class="edge"><title>j->h</title>
|
||||
<path fill="none" stroke="black" d="M436.857,-126.646C447.841,-119.73 463.1,-110.122 476.194,-101.878"/>
|
||||
<polygon fill="black" stroke="black" points="478.237,-104.727 484.835,-96.4375 474.507,-98.8038 478.237,-104.727"/>
|
||||
<text text-anchor="middle" x="460.5" y="-116.8" font-family="Times,serif" font-size="14.00">1</text>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 11 KiB |
|
|
@ -1,19 +1,18 @@
|
|||
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<!DOCTYPE html>
|
||||
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=Edge" />
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<meta charset="utf-8" />
|
||||
<title>Overview: module code — Thun 0.2.0 documentation</title>
|
||||
<link rel="stylesheet" href="../_static/alabaster.css" type="text/css" />
|
||||
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
|
||||
<script type="text/javascript" src="../_static/documentation_options.js"></script>
|
||||
<script type="text/javascript" src="../_static/jquery.js"></script>
|
||||
<script type="text/javascript" src="../_static/underscore.js"></script>
|
||||
<script type="text/javascript" src="../_static/doctools.js"></script>
|
||||
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
|
||||
<script id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script>
|
||||
<script src="../_static/jquery.js"></script>
|
||||
<script src="../_static/underscore.js"></script>
|
||||
<script src="../_static/doctools.js"></script>
|
||||
<script src="../_static/language_data.js"></script>
|
||||
<script async="async" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/latest.js?config=TeX-AMS-MML_HTMLorMML"></script>
|
||||
<link rel="index" title="Index" href="../genindex.html" />
|
||||
<link rel="search" title="Search" href="../search.html" />
|
||||
|
||||
|
|
@ -28,10 +27,12 @@
|
|||
<div class="document">
|
||||
<div class="documentwrapper">
|
||||
<div class="bodywrapper">
|
||||
|
||||
|
||||
<div class="body" role="main">
|
||||
|
||||
<h1>All modules for which code is available</h1>
|
||||
<ul><li><a href="__builtin__.html">__builtin__</a></li>
|
||||
<ul><li><a href="builtins.html">builtins</a></li>
|
||||
<li><a href="joy/joy.html">joy.joy</a></li>
|
||||
<li><a href="joy/library.html">joy.library</a></li>
|
||||
<li><a href="joy/parser.html">joy.parser</a></li>
|
||||
|
|
@ -39,13 +40,38 @@
|
|||
<li><a href="joy/utils/pretty_print.html">joy.utils.pretty_print</a></li>
|
||||
<li><a href="joy/utils/stack.html">joy.utils.stack</a></li>
|
||||
<li><a href="joy/utils/types.html">joy.utils.types</a></li>
|
||||
<li><a href="past/types/basestring.html">past.types.basestring</a></li>
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
|
||||
<div class="sphinxsidebarwrapper"><div class="relations">
|
||||
<div class="sphinxsidebarwrapper">
|
||||
<h1 class="logo"><a href="../index.html">Thun</a></h1>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h3>Navigation</h3>
|
||||
<ul>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../notebooks/Intro.html">Thun: Joy in Python</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../joy.html">Joy Interpreter</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../stack.html">Stack or Quote or Sequence or List…</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../parser.html">Parsing Text into Joy Expressions</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../pretty.html">Tracing Joy Execution</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../library.html">Function Reference</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../lib.html">Functions Grouped by, er, Function with Examples</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../types.html">Type Inference of Joy Expressions</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../notebooks/index.html">Essays about Programming in Joy</a></li>
|
||||
</ul>
|
||||
|
||||
<div class="relations">
|
||||
<h3>Related Topics</h3>
|
||||
<ul>
|
||||
<li><a href="../index.html">Documentation overview</a><ul>
|
||||
|
|
@ -53,17 +79,23 @@
|
|||
</ul>
|
||||
</div>
|
||||
<div id="searchbox" style="display: none" role="search">
|
||||
<h3>Quick search</h3>
|
||||
<h3 id="searchlabel">Quick search</h3>
|
||||
<div class="searchformwrapper">
|
||||
<form class="search" action="../search.html" method="get">
|
||||
<input type="text" name="q" />
|
||||
<input type="text" name="q" aria-labelledby="searchlabel" />
|
||||
<input type="submit" value="Go" />
|
||||
<input type="hidden" name="check_keywords" value="yes" />
|
||||
<input type="hidden" name="area" value="default" />
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">$('#searchbox').show(0);</script>
|
||||
<script>$('#searchbox').show(0);</script>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="clearer"></div>
|
||||
|
|
@ -74,7 +106,7 @@
|
|||
</a>
|
||||
<br />
|
||||
<span xmlns:dct="http://purl.org/dc/terms/" property="dct:title">Thun Documentation</span> by <a xmlns:cc="http://creativecommons.org/ns#" href="https://joypy.osdn.io/" property="cc:attributionName" rel="cc:attributionURL">Simon Forman</a> is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/4.0/">Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License</a>.<br />Based on a work at <a xmlns:dct="http://purl.org/dc/terms/" href="https://osdn.net/projects/joypy/" rel="dct:source">https://osdn.net/projects/joypy/</a>.
|
||||
Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.7.3.
|
||||
Created using <a href="http://sphinx-doc.org/">Sphinx</a> 3.0.2.
|
||||
</div>
|
||||
|
||||
</body>
|
||||
|
|
|
|||
|
|
@ -1,19 +1,18 @@
|
|||
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<!DOCTYPE html>
|
||||
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=Edge" />
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<meta charset="utf-8" />
|
||||
<title>joy.joy — Thun 0.2.0 documentation</title>
|
||||
<link rel="stylesheet" href="../../_static/alabaster.css" type="text/css" />
|
||||
<link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />
|
||||
<script type="text/javascript" src="../../_static/documentation_options.js"></script>
|
||||
<script type="text/javascript" src="../../_static/jquery.js"></script>
|
||||
<script type="text/javascript" src="../../_static/underscore.js"></script>
|
||||
<script type="text/javascript" src="../../_static/doctools.js"></script>
|
||||
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
|
||||
<script id="documentation_options" data-url_root="../../" src="../../_static/documentation_options.js"></script>
|
||||
<script src="../../_static/jquery.js"></script>
|
||||
<script src="../../_static/underscore.js"></script>
|
||||
<script src="../../_static/doctools.js"></script>
|
||||
<script src="../../_static/language_data.js"></script>
|
||||
<script async="async" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/latest.js?config=TeX-AMS-MML_HTMLorMML"></script>
|
||||
<link rel="index" title="Index" href="../../genindex.html" />
|
||||
<link rel="search" title="Search" href="../../search.html" />
|
||||
|
||||
|
|
@ -28,6 +27,8 @@
|
|||
<div class="document">
|
||||
<div class="documentwrapper">
|
||||
<div class="bodywrapper">
|
||||
|
||||
|
||||
<div class="body" role="main">
|
||||
|
||||
<h1>Source code for joy.joy</h1><div class="highlight"><pre>
|
||||
|
|
@ -56,12 +57,11 @@
|
|||
<span class="sd">match the behaviour of the original version(s) written in C.</span>
|
||||
|
||||
<span class="sd">'''</span>
|
||||
<span class="kn">from</span> <span class="nn">__future__</span> <span class="k">import</span> <span class="n">print_function</span>
|
||||
<span class="kn">from</span> <span class="nn">builtins</span> <span class="k">import</span> <span class="nb">input</span>
|
||||
<span class="kn">from</span> <span class="nn">traceback</span> <span class="k">import</span> <span class="n">print_exc</span><span class="p">,</span> <span class="n">format_exc</span>
|
||||
<span class="kn">from</span> <span class="nn">.parser</span> <span class="k">import</span> <span class="n">text_to_expression</span><span class="p">,</span> <span class="n">ParseError</span><span class="p">,</span> <span class="n">Symbol</span>
|
||||
<span class="kn">from</span> <span class="nn">.utils.stack</span> <span class="k">import</span> <span class="n">stack_to_string</span>
|
||||
<span class="kn">from</span> <span class="nn">.utils.pretty_print</span> <span class="k">import</span> <span class="n">TracePrinter</span>
|
||||
<span class="kn">from</span> <span class="nn">__future__</span> <span class="kn">import</span> <span class="n">print_function</span>
|
||||
<span class="kn">from</span> <span class="nn">builtins</span> <span class="kn">import</span> <span class="nb">input</span>
|
||||
<span class="kn">from</span> <span class="nn">traceback</span> <span class="kn">import</span> <span class="n">print_exc</span><span class="p">,</span> <span class="n">format_exc</span>
|
||||
<span class="kn">from</span> <span class="nn">.parser</span> <span class="kn">import</span> <span class="n">text_to_expression</span><span class="p">,</span> <span class="n">ParseError</span><span class="p">,</span> <span class="n">Symbol</span>
|
||||
<span class="kn">from</span> <span class="nn">.utils.stack</span> <span class="kn">import</span> <span class="n">stack_to_string</span>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="joy"><a class="viewcode-back" href="../../joy.html#joy.joy.joy">[docs]</a><span class="k">def</span> <span class="nf">joy</span><span class="p">(</span><span class="n">stack</span><span class="p">,</span> <span class="n">expression</span><span class="p">,</span> <span class="n">dictionary</span><span class="p">,</span> <span class="n">viewer</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
|
||||
|
|
@ -134,16 +134,11 @@
|
|||
<span class="n">text</span> <span class="o">=</span> <span class="nb">input</span><span class="p">(</span><span class="s1">'joy? '</span><span class="p">)</span>
|
||||
<span class="k">except</span> <span class="p">(</span><span class="ne">EOFError</span><span class="p">,</span> <span class="ne">KeyboardInterrupt</span><span class="p">):</span>
|
||||
<span class="k">break</span>
|
||||
<span class="n">viewer</span> <span class="o">=</span> <span class="n">TracePrinter</span><span class="p">()</span>
|
||||
<span class="k">try</span><span class="p">:</span>
|
||||
<span class="n">stack</span><span class="p">,</span> <span class="n">_</span><span class="p">,</span> <span class="n">dictionary</span> <span class="o">=</span> <span class="n">run</span><span class="p">(</span><span class="n">text</span><span class="p">,</span> <span class="n">stack</span><span class="p">,</span> <span class="n">dictionary</span><span class="p">,</span> <span class="n">viewer</span><span class="o">.</span><span class="n">viewer</span><span class="p">)</span>
|
||||
<span class="n">stack</span><span class="p">,</span> <span class="n">_</span><span class="p">,</span> <span class="n">dictionary</span> <span class="o">=</span> <span class="n">run</span><span class="p">(</span><span class="n">text</span><span class="p">,</span> <span class="n">stack</span><span class="p">,</span> <span class="n">dictionary</span><span class="p">)</span>
|
||||
<span class="k">except</span><span class="p">:</span>
|
||||
<span class="n">exc</span> <span class="o">=</span> <span class="n">format_exc</span><span class="p">()</span> <span class="c1"># Capture the exception.</span>
|
||||
<span class="n">viewer</span><span class="o">.</span><span class="n">print_</span><span class="p">()</span> <span class="c1"># Print the Joy trace.</span>
|
||||
<span class="nb">print</span><span class="p">(</span><span class="s1">'-'</span> <span class="o">*</span> <span class="mi">73</span><span class="p">)</span>
|
||||
<span class="nb">print</span><span class="p">(</span><span class="n">exc</span><span class="p">)</span> <span class="c1"># Print the original exception.</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="n">viewer</span><span class="o">.</span><span class="n">print_</span><span class="p">()</span>
|
||||
<span class="k">except</span><span class="p">:</span>
|
||||
<span class="n">print_exc</span><span class="p">()</span>
|
||||
<span class="nb">print</span><span class="p">()</span>
|
||||
|
|
@ -151,10 +146,34 @@
|
|||
</pre></div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
|
||||
<div class="sphinxsidebarwrapper"><div class="relations">
|
||||
<div class="sphinxsidebarwrapper">
|
||||
<h1 class="logo"><a href="../../index.html">Thun</a></h1>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h3>Navigation</h3>
|
||||
<ul>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../notebooks/Intro.html">Thun: Joy in Python</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../joy.html">Joy Interpreter</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../stack.html">Stack or Quote or Sequence or List…</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../parser.html">Parsing Text into Joy Expressions</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../pretty.html">Tracing Joy Execution</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../library.html">Function Reference</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../lib.html">Functions Grouped by, er, Function with Examples</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../types.html">Type Inference of Joy Expressions</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../notebooks/index.html">Essays about Programming in Joy</a></li>
|
||||
</ul>
|
||||
|
||||
<div class="relations">
|
||||
<h3>Related Topics</h3>
|
||||
<ul>
|
||||
<li><a href="../../index.html">Documentation overview</a><ul>
|
||||
|
|
@ -164,17 +183,23 @@
|
|||
</ul>
|
||||
</div>
|
||||
<div id="searchbox" style="display: none" role="search">
|
||||
<h3>Quick search</h3>
|
||||
<h3 id="searchlabel">Quick search</h3>
|
||||
<div class="searchformwrapper">
|
||||
<form class="search" action="../../search.html" method="get">
|
||||
<input type="text" name="q" />
|
||||
<input type="text" name="q" aria-labelledby="searchlabel" />
|
||||
<input type="submit" value="Go" />
|
||||
<input type="hidden" name="check_keywords" value="yes" />
|
||||
<input type="hidden" name="area" value="default" />
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">$('#searchbox').show(0);</script>
|
||||
<script>$('#searchbox').show(0);</script>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="clearer"></div>
|
||||
|
|
@ -185,7 +210,7 @@
|
|||
</a>
|
||||
<br />
|
||||
<span xmlns:dct="http://purl.org/dc/terms/" property="dct:title">Thun Documentation</span> by <a xmlns:cc="http://creativecommons.org/ns#" href="https://joypy.osdn.io/" property="cc:attributionName" rel="cc:attributionURL">Simon Forman</a> is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/4.0/">Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License</a>.<br />Based on a work at <a xmlns:dct="http://purl.org/dc/terms/" href="https://osdn.net/projects/joypy/" rel="dct:source">https://osdn.net/projects/joypy/</a>.
|
||||
Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.7.3.
|
||||
Created using <a href="http://sphinx-doc.org/">Sphinx</a> 3.0.2.
|
||||
</div>
|
||||
|
||||
</body>
|
||||
|
|
|
|||
|
|
@ -1,19 +1,18 @@
|
|||
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<!DOCTYPE html>
|
||||
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=Edge" />
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<meta charset="utf-8" />
|
||||
<title>joy.library — Thun 0.2.0 documentation</title>
|
||||
<link rel="stylesheet" href="../../_static/alabaster.css" type="text/css" />
|
||||
<link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />
|
||||
<script type="text/javascript" src="../../_static/documentation_options.js"></script>
|
||||
<script type="text/javascript" src="../../_static/jquery.js"></script>
|
||||
<script type="text/javascript" src="../../_static/underscore.js"></script>
|
||||
<script type="text/javascript" src="../../_static/doctools.js"></script>
|
||||
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
|
||||
<script id="documentation_options" data-url_root="../../" src="../../_static/documentation_options.js"></script>
|
||||
<script src="../../_static/jquery.js"></script>
|
||||
<script src="../../_static/underscore.js"></script>
|
||||
<script src="../../_static/doctools.js"></script>
|
||||
<script src="../../_static/language_data.js"></script>
|
||||
<script async="async" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/latest.js?config=TeX-AMS-MML_HTMLorMML"></script>
|
||||
<link rel="index" title="Index" href="../../genindex.html" />
|
||||
<link rel="search" title="Search" href="../../search.html" />
|
||||
|
||||
|
|
@ -28,6 +27,8 @@
|
|||
<div class="document">
|
||||
<div class="documentwrapper">
|
||||
<div class="bodywrapper">
|
||||
|
||||
|
||||
<div class="body" role="main">
|
||||
|
||||
<h1>Source code for joy.library</h1><div class="highlight"><pre>
|
||||
|
|
@ -56,29 +57,29 @@
|
|||
<span class="sd">returns a dictionary of Joy functions suitable for use with the joy()</span>
|
||||
<span class="sd">function.</span>
|
||||
<span class="sd">'''</span>
|
||||
<span class="kn">from</span> <span class="nn">__future__</span> <span class="k">import</span> <span class="n">print_function</span>
|
||||
<span class="kn">from</span> <span class="nn">builtins</span> <span class="k">import</span> <span class="nb">map</span><span class="p">,</span> <span class="nb">object</span><span class="p">,</span> <span class="nb">range</span><span class="p">,</span> <span class="nb">zip</span>
|
||||
<span class="kn">from</span> <span class="nn">logging</span> <span class="k">import</span> <span class="n">getLogger</span>
|
||||
<span class="kn">from</span> <span class="nn">__future__</span> <span class="kn">import</span> <span class="n">print_function</span>
|
||||
<span class="kn">from</span> <span class="nn">builtins</span> <span class="kn">import</span> <span class="nb">map</span><span class="p">,</span> <span class="nb">object</span><span class="p">,</span> <span class="nb">range</span><span class="p">,</span> <span class="nb">zip</span>
|
||||
<span class="kn">from</span> <span class="nn">logging</span> <span class="kn">import</span> <span class="n">getLogger</span>
|
||||
|
||||
<span class="n">_log</span> <span class="o">=</span> <span class="n">getLogger</span><span class="p">(</span><span class="vm">__name__</span><span class="p">)</span>
|
||||
<span class="n">_log</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="s1">'Loading library.'</span><span class="p">)</span>
|
||||
|
||||
<span class="kn">from</span> <span class="nn">inspect</span> <span class="k">import</span> <span class="n">getdoc</span>
|
||||
<span class="kn">from</span> <span class="nn">functools</span> <span class="k">import</span> <span class="n">wraps</span>
|
||||
<span class="kn">from</span> <span class="nn">itertools</span> <span class="k">import</span> <span class="n">count</span>
|
||||
<span class="kn">from</span> <span class="nn">inspect</span> <span class="k">import</span> <span class="n">getmembers</span><span class="p">,</span> <span class="n">isfunction</span>
|
||||
<span class="kn">from</span> <span class="nn">inspect</span> <span class="kn">import</span> <span class="n">getdoc</span>
|
||||
<span class="kn">from</span> <span class="nn">functools</span> <span class="kn">import</span> <span class="n">wraps</span>
|
||||
<span class="kn">from</span> <span class="nn">itertools</span> <span class="kn">import</span> <span class="n">count</span>
|
||||
<span class="kn">from</span> <span class="nn">inspect</span> <span class="kn">import</span> <span class="n">getmembers</span><span class="p">,</span> <span class="n">isfunction</span>
|
||||
<span class="kn">import</span> <span class="nn">operator</span><span class="o">,</span> <span class="nn">math</span>
|
||||
|
||||
<span class="kn">from</span> <span class="nn">.parser</span> <span class="k">import</span> <span class="n">text_to_expression</span><span class="p">,</span> <span class="n">Symbol</span>
|
||||
<span class="kn">from</span> <span class="nn">.utils.stack</span> <span class="k">import</span> <span class="n">expression_to_string</span><span class="p">,</span> <span class="n">list_to_stack</span><span class="p">,</span> <span class="n">iter_stack</span><span class="p">,</span> <span class="n">pick</span><span class="p">,</span> <span class="n">concat</span>
|
||||
<span class="kn">from</span> <span class="nn">.parser</span> <span class="kn">import</span> <span class="n">text_to_expression</span><span class="p">,</span> <span class="n">Symbol</span>
|
||||
<span class="kn">from</span> <span class="nn">.utils.stack</span> <span class="kn">import</span> <span class="n">expression_to_string</span><span class="p">,</span> <span class="n">list_to_stack</span><span class="p">,</span> <span class="n">iter_stack</span><span class="p">,</span> <span class="n">pick</span><span class="p">,</span> <span class="n">concat</span>
|
||||
<span class="kn">import</span> <span class="nn">sys</span>
|
||||
<span class="k">if</span> <span class="n">sys</span><span class="o">.</span><span class="n">version_info</span><span class="o">.</span><span class="n">major</span> <span class="o"><</span> <span class="mi">3</span><span class="p">:</span>
|
||||
<span class="kn">from</span> <span class="nn">.utils.brutal_hackery</span> <span class="k">import</span> <span class="n">rename_code_object</span>
|
||||
<span class="kn">from</span> <span class="nn">.utils.brutal_hackery</span> <span class="kn">import</span> <span class="n">rename_code_object</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="n">rename_code_object</span> <span class="o">=</span> <span class="k">lambda</span> <span class="n">_</span><span class="p">:</span> <span class="k">lambda</span> <span class="n">f</span><span class="p">:</span> <span class="n">f</span>
|
||||
|
||||
<span class="kn">from</span> <span class="nn">.utils</span> <span class="k">import</span> <span class="n">generated_library</span> <span class="k">as</span> <span class="n">genlib</span>
|
||||
<span class="kn">from</span> <span class="nn">.utils.types</span> <span class="k">import</span> <span class="p">(</span>
|
||||
<span class="kn">from</span> <span class="nn">.utils</span> <span class="kn">import</span> <span class="n">generated_library</span> <span class="k">as</span> <span class="n">genlib</span>
|
||||
<span class="kn">from</span> <span class="nn">.utils.types</span> <span class="kn">import</span> <span class="p">(</span>
|
||||
<span class="n">compose</span><span class="p">,</span>
|
||||
<span class="n">ef</span><span class="p">,</span>
|
||||
<span class="n">stack_effect</span><span class="p">,</span>
|
||||
|
|
@ -167,7 +168,7 @@
|
|||
<span class="p">(</span><span class="s1">'mul'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'*'</span><span class="p">]),</span>
|
||||
<span class="p">(</span><span class="s1">'floordiv'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'/floor'</span><span class="p">,</span> <span class="s1">'//'</span><span class="p">]),</span>
|
||||
<span class="p">(</span><span class="s1">'floor'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'round'</span><span class="p">]),</span>
|
||||
<span class="p">(</span><span class="s1">'truediv'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'/'</span><span class="p">]),</span>
|
||||
<span class="p">(</span><span class="s1">'truediv'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'/'</span><span class="p">,</span> <span class="s1">'div'</span><span class="p">]),</span>
|
||||
<span class="p">(</span><span class="s1">'mod'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'%'</span><span class="p">,</span> <span class="s1">'rem'</span><span class="p">,</span> <span class="s1">'remainder'</span><span class="p">,</span> <span class="s1">'modulus'</span><span class="p">]),</span>
|
||||
<span class="p">(</span><span class="s1">'eq'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'='</span><span class="p">]),</span>
|
||||
<span class="p">(</span><span class="s1">'ge'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'>='</span><span class="p">]),</span>
|
||||
|
|
@ -264,7 +265,7 @@
|
|||
<span class="s1">cleave == fork [popd] dip</span>
|
||||
<span class="s1">codireco == cons dip rest cons</span>
|
||||
<span class="s1">dinfrirst == dip infra first</span>
|
||||
<span class="s1">disenstacken == ? [uncons ?] loop pop</span>
|
||||
<span class="s1">unstack == ? [uncons ?] loop pop</span>
|
||||
<span class="s1">down_to_zero == [0 >] [dup --] while</span>
|
||||
<span class="s1">dupdipd == dup dipd</span>
|
||||
<span class="s1">enstacken == stack [clear] dip</span>
|
||||
|
|
@ -278,7 +279,7 @@
|
|||
<span class="s1">nullary == [stack] dinfrirst</span>
|
||||
<span class="s1">of == swap at</span>
|
||||
<span class="s1">pam == [i] map</span>
|
||||
<span class="s1">primrec == [i] genrec</span>
|
||||
<span class="s1">tailrec == [i] genrec</span>
|
||||
<span class="s1">product == 1 swap [*] step</span>
|
||||
<span class="s1">quoted == [unit] dip</span>
|
||||
<span class="s1">range == [0 <=] [1 - dup] anamorphism</span>
|
||||
|
|
@ -388,14 +389,14 @@
|
|||
<span class="sd"> Provide implementation of defined functions, and some helper methods.</span>
|
||||
<span class="sd"> '''</span>
|
||||
|
||||
<span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">name</span><span class="p">,</span> <span class="n">body_text</span><span class="p">,</span> <span class="n">doc</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
|
||||
<span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">name</span><span class="p">,</span> <span class="n">body_text</span><span class="p">,</span> <span class="n">doc</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">name</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="vm">__name__</span> <span class="o">=</span> <span class="n">name</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">body</span> <span class="o">=</span> <span class="n">text_to_expression</span><span class="p">(</span><span class="n">body_text</span><span class="p">)</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_body</span> <span class="o">=</span> <span class="nb">tuple</span><span class="p">(</span><span class="n">iter_stack</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">body</span><span class="p">))</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="vm">__doc__</span> <span class="o">=</span> <span class="n">doc</span> <span class="ow">or</span> <span class="n">body_text</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_compiled</span> <span class="o">=</span> <span class="kc">None</span>
|
||||
|
||||
<span class="k">def</span> <span class="nf">__call__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">stack</span><span class="p">,</span> <span class="n">expression</span><span class="p">,</span> <span class="n">dictionary</span><span class="p">):</span>
|
||||
<span class="k">def</span> <span class="fm">__call__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">stack</span><span class="p">,</span> <span class="n">expression</span><span class="p">,</span> <span class="n">dictionary</span><span class="p">):</span>
|
||||
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_compiled</span><span class="p">:</span>
|
||||
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_compiled</span><span class="p">(</span><span class="n">stack</span><span class="p">,</span> <span class="n">expression</span><span class="p">,</span> <span class="n">dictionary</span><span class="p">)</span> <span class="c1"># pylint: disable=E1102</span>
|
||||
<span class="n">expression</span> <span class="o">=</span> <span class="n">list_to_stack</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_body</span><span class="p">,</span> <span class="n">expression</span><span class="p">)</span>
|
||||
|
|
@ -692,11 +693,11 @@
|
|||
<span class="k">return</span> <span class="p">()</span></div>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="unstack"><a class="viewcode-back" href="../../library.html#joy.library.unstack">[docs]</a><span class="nd">@inscribe</span>
|
||||
<div class="viewcode-block" id="disenstacken"><a class="viewcode-back" href="../../library.html#joy.library.disenstacken">[docs]</a><span class="nd">@inscribe</span>
|
||||
<span class="nd">@SimpleFunctionWrapper</span>
|
||||
<span class="k">def</span> <span class="nf">unstack</span><span class="p">(</span><span class="n">stack</span><span class="p">):</span>
|
||||
<span class="k">def</span> <span class="nf">disenstacken</span><span class="p">(</span><span class="n">stack</span><span class="p">):</span>
|
||||
<span class="sd">'''</span>
|
||||
<span class="sd"> The unstack operator expects a list on top of the stack and makes that</span>
|
||||
<span class="sd"> The disenstacken operator expects a list on top of the stack and makes that</span>
|
||||
<span class="sd"> the stack discarding the rest of the stack.</span>
|
||||
<span class="sd"> '''</span>
|
||||
<span class="k">return</span> <span class="n">stack</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span></div>
|
||||
|
|
@ -1100,7 +1101,7 @@
|
|||
<span class="sd"> Primitive recursive functions are those where R2 == i.</span>
|
||||
<span class="sd"> ::</span>
|
||||
|
||||
<span class="sd"> P == [I] [T] [R] primrec</span>
|
||||
<span class="sd"> P == [I] [T] [R] tailrec</span>
|
||||
<span class="sd"> == [I] [T] [R [P] i] ifte</span>
|
||||
<span class="sd"> == [I] [T] [R P] ifte</span>
|
||||
|
||||
|
|
@ -1456,7 +1457,7 @@
|
|||
<span class="c1"># --------------------------------------</span>
|
||||
<span class="c1"># [P] nullary [Q [P] nullary] loop</span>
|
||||
|
||||
<span class="c1"># while == [pop i not] [popop] [dudipd] primrec</span>
|
||||
<span class="c1"># while == [pop i not] [popop] [dudipd] tailrec</span>
|
||||
|
||||
<span class="c1">#def while_(S, expression, dictionary):</span>
|
||||
<span class="c1"># '''[if] [body] while'''</span>
|
||||
|
|
@ -1647,7 +1648,6 @@
|
|||
|
||||
<span class="c1">## product == 1 swap [*] step</span>
|
||||
<span class="c1">## flatten == [] swap [concat] step</span>
|
||||
<span class="c1">## disenstacken == ? [uncons ?] loop pop</span>
|
||||
<span class="c1">## pam == [i] map</span>
|
||||
<span class="c1">## size == 0 swap [pop ++] step</span>
|
||||
<span class="c1">## fork == [i] app2</span>
|
||||
|
|
@ -1663,7 +1663,7 @@
|
|||
<span class="c1">## range == [0 <=] [1 - dup] anamorphism</span>
|
||||
<span class="c1">## while == swap [nullary] cons dup dipd concat loop</span>
|
||||
<span class="c1">## dupdipd == dup dipd</span>
|
||||
<span class="c1">## primrec == [i] genrec</span>
|
||||
<span class="c1">## tailrec == [i] genrec</span>
|
||||
<span class="c1">## step_zero == 0 roll> step</span>
|
||||
<span class="c1">## codireco == cons dip rest cons</span>
|
||||
<span class="c1">## make_generator == [codireco] ccons</span>
|
||||
|
|
@ -1671,10 +1671,34 @@
|
|||
</pre></div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
|
||||
<div class="sphinxsidebarwrapper"><div class="relations">
|
||||
<div class="sphinxsidebarwrapper">
|
||||
<h1 class="logo"><a href="../../index.html">Thun</a></h1>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h3>Navigation</h3>
|
||||
<ul>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../notebooks/Intro.html">Thun: Joy in Python</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../joy.html">Joy Interpreter</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../stack.html">Stack or Quote or Sequence or List…</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../parser.html">Parsing Text into Joy Expressions</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../pretty.html">Tracing Joy Execution</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../library.html">Function Reference</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../lib.html">Functions Grouped by, er, Function with Examples</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../types.html">Type Inference of Joy Expressions</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../notebooks/index.html">Essays about Programming in Joy</a></li>
|
||||
</ul>
|
||||
|
||||
<div class="relations">
|
||||
<h3>Related Topics</h3>
|
||||
<ul>
|
||||
<li><a href="../../index.html">Documentation overview</a><ul>
|
||||
|
|
@ -1684,17 +1708,23 @@
|
|||
</ul>
|
||||
</div>
|
||||
<div id="searchbox" style="display: none" role="search">
|
||||
<h3>Quick search</h3>
|
||||
<h3 id="searchlabel">Quick search</h3>
|
||||
<div class="searchformwrapper">
|
||||
<form class="search" action="../../search.html" method="get">
|
||||
<input type="text" name="q" />
|
||||
<input type="text" name="q" aria-labelledby="searchlabel" />
|
||||
<input type="submit" value="Go" />
|
||||
<input type="hidden" name="check_keywords" value="yes" />
|
||||
<input type="hidden" name="area" value="default" />
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">$('#searchbox').show(0);</script>
|
||||
<script>$('#searchbox').show(0);</script>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="clearer"></div>
|
||||
|
|
@ -1705,7 +1735,7 @@
|
|||
</a>
|
||||
<br />
|
||||
<span xmlns:dct="http://purl.org/dc/terms/" property="dct:title">Thun Documentation</span> by <a xmlns:cc="http://creativecommons.org/ns#" href="https://joypy.osdn.io/" property="cc:attributionName" rel="cc:attributionURL">Simon Forman</a> is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/4.0/">Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License</a>.<br />Based on a work at <a xmlns:dct="http://purl.org/dc/terms/" href="https://osdn.net/projects/joypy/" rel="dct:source">https://osdn.net/projects/joypy/</a>.
|
||||
Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.7.3.
|
||||
Created using <a href="http://sphinx-doc.org/">Sphinx</a> 3.0.2.
|
||||
</div>
|
||||
|
||||
</body>
|
||||
|
|
|
|||
|
|
@ -1,19 +1,18 @@
|
|||
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<!DOCTYPE html>
|
||||
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=Edge" />
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<meta charset="utf-8" />
|
||||
<title>joy.parser — Thun 0.2.0 documentation</title>
|
||||
<link rel="stylesheet" href="../../_static/alabaster.css" type="text/css" />
|
||||
<link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />
|
||||
<script type="text/javascript" src="../../_static/documentation_options.js"></script>
|
||||
<script type="text/javascript" src="../../_static/jquery.js"></script>
|
||||
<script type="text/javascript" src="../../_static/underscore.js"></script>
|
||||
<script type="text/javascript" src="../../_static/doctools.js"></script>
|
||||
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
|
||||
<script id="documentation_options" data-url_root="../../" src="../../_static/documentation_options.js"></script>
|
||||
<script src="../../_static/jquery.js"></script>
|
||||
<script src="../../_static/underscore.js"></script>
|
||||
<script src="../../_static/doctools.js"></script>
|
||||
<script src="../../_static/language_data.js"></script>
|
||||
<script async="async" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/latest.js?config=TeX-AMS-MML_HTMLorMML"></script>
|
||||
<link rel="index" title="Index" href="../../genindex.html" />
|
||||
<link rel="search" title="Search" href="../../search.html" />
|
||||
|
||||
|
|
@ -28,6 +27,8 @@
|
|||
<div class="document">
|
||||
<div class="documentwrapper">
|
||||
<div class="bodywrapper">
|
||||
|
||||
|
||||
<div class="body" role="main">
|
||||
|
||||
<h1>Source code for joy.parser</h1><div class="highlight"><pre>
|
||||
|
|
@ -69,8 +70,8 @@
|
|||
<span class="sd">around square brackets.</span>
|
||||
|
||||
<span class="sd">'''</span>
|
||||
<span class="kn">from</span> <span class="nn">re</span> <span class="k">import</span> <span class="n">Scanner</span>
|
||||
<span class="kn">from</span> <span class="nn">.utils.stack</span> <span class="k">import</span> <span class="n">list_to_stack</span>
|
||||
<span class="kn">from</span> <span class="nn">re</span> <span class="kn">import</span> <span class="n">Scanner</span>
|
||||
<span class="kn">from</span> <span class="nn">.utils.stack</span> <span class="kn">import</span> <span class="n">list_to_stack</span>
|
||||
|
||||
|
||||
<span class="c1">#TODO: explain the details of float lits and strings.</span>
|
||||
|
|
@ -158,10 +159,34 @@
|
|||
</pre></div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
|
||||
<div class="sphinxsidebarwrapper"><div class="relations">
|
||||
<div class="sphinxsidebarwrapper">
|
||||
<h1 class="logo"><a href="../../index.html">Thun</a></h1>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h3>Navigation</h3>
|
||||
<ul>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../notebooks/Intro.html">Thun: Joy in Python</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../joy.html">Joy Interpreter</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../stack.html">Stack or Quote or Sequence or List…</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../parser.html">Parsing Text into Joy Expressions</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../pretty.html">Tracing Joy Execution</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../library.html">Function Reference</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../lib.html">Functions Grouped by, er, Function with Examples</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../types.html">Type Inference of Joy Expressions</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../notebooks/index.html">Essays about Programming in Joy</a></li>
|
||||
</ul>
|
||||
|
||||
<div class="relations">
|
||||
<h3>Related Topics</h3>
|
||||
<ul>
|
||||
<li><a href="../../index.html">Documentation overview</a><ul>
|
||||
|
|
@ -171,17 +196,23 @@
|
|||
</ul>
|
||||
</div>
|
||||
<div id="searchbox" style="display: none" role="search">
|
||||
<h3>Quick search</h3>
|
||||
<h3 id="searchlabel">Quick search</h3>
|
||||
<div class="searchformwrapper">
|
||||
<form class="search" action="../../search.html" method="get">
|
||||
<input type="text" name="q" />
|
||||
<input type="text" name="q" aria-labelledby="searchlabel" />
|
||||
<input type="submit" value="Go" />
|
||||
<input type="hidden" name="check_keywords" value="yes" />
|
||||
<input type="hidden" name="area" value="default" />
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">$('#searchbox').show(0);</script>
|
||||
<script>$('#searchbox').show(0);</script>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="clearer"></div>
|
||||
|
|
@ -192,7 +223,7 @@
|
|||
</a>
|
||||
<br />
|
||||
<span xmlns:dct="http://purl.org/dc/terms/" property="dct:title">Thun Documentation</span> by <a xmlns:cc="http://creativecommons.org/ns#" href="https://joypy.osdn.io/" property="cc:attributionName" rel="cc:attributionURL">Simon Forman</a> is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/4.0/">Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License</a>.<br />Based on a work at <a xmlns:dct="http://purl.org/dc/terms/" href="https://osdn.net/projects/joypy/" rel="dct:source">https://osdn.net/projects/joypy/</a>.
|
||||
Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.7.3.
|
||||
Created using <a href="http://sphinx-doc.org/">Sphinx</a> 3.0.2.
|
||||
</div>
|
||||
|
||||
</body>
|
||||
|
|
|
|||
|
|
@ -1,19 +1,18 @@
|
|||
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<!DOCTYPE html>
|
||||
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=Edge" />
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<meta charset="utf-8" />
|
||||
<title>joy.utils.pretty_print — Thun 0.2.0 documentation</title>
|
||||
<link rel="stylesheet" href="../../../_static/alabaster.css" type="text/css" />
|
||||
<link rel="stylesheet" href="../../../_static/pygments.css" type="text/css" />
|
||||
<script type="text/javascript" src="../../../_static/documentation_options.js"></script>
|
||||
<script type="text/javascript" src="../../../_static/jquery.js"></script>
|
||||
<script type="text/javascript" src="../../../_static/underscore.js"></script>
|
||||
<script type="text/javascript" src="../../../_static/doctools.js"></script>
|
||||
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
|
||||
<script id="documentation_options" data-url_root="../../../" src="../../../_static/documentation_options.js"></script>
|
||||
<script src="../../../_static/jquery.js"></script>
|
||||
<script src="../../../_static/underscore.js"></script>
|
||||
<script src="../../../_static/doctools.js"></script>
|
||||
<script src="../../../_static/language_data.js"></script>
|
||||
<script async="async" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/latest.js?config=TeX-AMS-MML_HTMLorMML"></script>
|
||||
<link rel="index" title="Index" href="../../../genindex.html" />
|
||||
<link rel="search" title="Search" href="../../../search.html" />
|
||||
|
||||
|
|
@ -28,6 +27,8 @@
|
|||
<div class="document">
|
||||
<div class="documentwrapper">
|
||||
<div class="bodywrapper">
|
||||
|
||||
|
||||
<div class="body" role="main">
|
||||
|
||||
<h1>Source code for joy.utils.pretty_print</h1><div class="highlight"><pre>
|
||||
|
|
@ -72,10 +73,39 @@
|
|||
<span class="sd">'''</span>
|
||||
<span class="c1"># (Kinda clunky and hacky. This should be swapped out in favor of much</span>
|
||||
<span class="c1"># smarter stuff.)</span>
|
||||
<span class="kn">from</span> <span class="nn">__future__</span> <span class="k">import</span> <span class="n">print_function</span>
|
||||
<span class="kn">from</span> <span class="nn">builtins</span> <span class="k">import</span> <span class="nb">object</span>
|
||||
<span class="kn">from</span> <span class="nn">traceback</span> <span class="k">import</span> <span class="n">print_exc</span>
|
||||
<span class="kn">from</span> <span class="nn">.stack</span> <span class="k">import</span> <span class="n">expression_to_string</span><span class="p">,</span> <span class="n">stack_to_string</span>
|
||||
<span class="kn">from</span> <span class="nn">__future__</span> <span class="kn">import</span> <span class="n">print_function</span>
|
||||
<span class="kn">from</span> <span class="nn">builtins</span> <span class="kn">import</span> <span class="nb">object</span>
|
||||
<span class="kn">from</span> <span class="nn">traceback</span> <span class="kn">import</span> <span class="n">print_exc</span>
|
||||
<span class="kn">from</span> <span class="nn">.stack</span> <span class="kn">import</span> <span class="n">expression_to_string</span><span class="p">,</span> <span class="n">stack_to_string</span>
|
||||
<span class="kn">from</span> <span class="nn">..joy</span> <span class="kn">import</span> <span class="n">joy</span>
|
||||
<span class="kn">from</span> <span class="nn">..library</span> <span class="kn">import</span> <span class="n">inscribe</span><span class="p">,</span> <span class="n">FunctionWrapper</span>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="trace"><a class="viewcode-back" href="../../../pretty.html#joy.utils.pretty_print.trace">[docs]</a><span class="nd">@inscribe</span>
|
||||
<span class="nd">@FunctionWrapper</span>
|
||||
<span class="k">def</span> <span class="nf">trace</span><span class="p">(</span><span class="n">stack</span><span class="p">,</span> <span class="n">expression</span><span class="p">,</span> <span class="n">dictionary</span><span class="p">):</span>
|
||||
<span class="sd">'''Evaluate a Joy expression on a stack and print a trace.</span>
|
||||
|
||||
<span class="sd"> This function is just like the `i` combinator but it also prints a</span>
|
||||
<span class="sd"> trace of the evaluation</span>
|
||||
|
||||
<span class="sd"> :param stack stack: The stack.</span>
|
||||
<span class="sd"> :param stack expression: The expression to evaluate.</span>
|
||||
<span class="sd"> :param dict dictionary: A ``dict`` mapping names to Joy functions.</span>
|
||||
<span class="sd"> :rtype: (stack, (), dictionary)</span>
|
||||
|
||||
<span class="sd"> '''</span>
|
||||
<span class="n">tp</span> <span class="o">=</span> <span class="n">TracePrinter</span><span class="p">()</span>
|
||||
<span class="n">quote</span><span class="p">,</span> <span class="n">stack</span> <span class="o">=</span> <span class="n">stack</span>
|
||||
<span class="k">try</span><span class="p">:</span>
|
||||
<span class="n">s</span><span class="p">,</span> <span class="n">_</span><span class="p">,</span> <span class="n">d</span> <span class="o">=</span> <span class="n">joy</span><span class="p">(</span><span class="n">stack</span><span class="p">,</span> <span class="n">quote</span><span class="p">,</span> <span class="n">dictionary</span><span class="p">,</span> <span class="n">tp</span><span class="o">.</span><span class="n">viewer</span><span class="p">)</span>
|
||||
<span class="k">except</span><span class="p">:</span>
|
||||
<span class="n">tp</span><span class="o">.</span><span class="n">print_</span><span class="p">()</span>
|
||||
<span class="nb">print</span><span class="p">(</span><span class="s1">'-'</span> <span class="o">*</span> <span class="mi">73</span><span class="p">)</span>
|
||||
<span class="k">raise</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="n">tp</span><span class="o">.</span><span class="n">print_</span><span class="p">()</span>
|
||||
<span class="k">return</span> <span class="n">s</span><span class="p">,</span> <span class="n">expression</span><span class="p">,</span> <span class="n">d</span></div>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="TracePrinter"><a class="viewcode-back" href="../../../pretty.html#joy.utils.pretty_print.TracePrinter">[docs]</a><span class="k">class</span> <span class="nc">TracePrinter</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
|
||||
|
|
@ -85,7 +115,7 @@
|
|||
<span class="sd"> trace.</span>
|
||||
<span class="sd"> '''</span>
|
||||
|
||||
<span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">history</span> <span class="o">=</span> <span class="p">[]</span>
|
||||
|
||||
<div class="viewcode-block" id="TracePrinter.viewer"><a class="viewcode-back" href="../../../pretty.html#joy.utils.pretty_print.TracePrinter.viewer">[docs]</a> <span class="k">def</span> <span class="nf">viewer</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">stack</span><span class="p">,</span> <span class="n">expression</span><span class="p">):</span>
|
||||
|
|
@ -98,7 +128,7 @@
|
|||
<span class="sd"> '''</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">history</span><span class="o">.</span><span class="n">append</span><span class="p">((</span><span class="n">stack</span><span class="p">,</span> <span class="n">expression</span><span class="p">))</span></div>
|
||||
|
||||
<span class="k">def</span> <span class="nf">__str__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="k">def</span> <span class="fm">__str__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="k">return</span> <span class="s1">'</span><span class="se">\n</span><span class="s1">'</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">go</span><span class="p">())</span>
|
||||
|
||||
<div class="viewcode-block" id="TracePrinter.go"><a class="viewcode-back" href="../../../pretty.html#joy.utils.pretty_print.TracePrinter.go">[docs]</a> <span class="k">def</span> <span class="nf">go</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
|
|
@ -133,10 +163,34 @@
|
|||
</pre></div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
|
||||
<div class="sphinxsidebarwrapper"><div class="relations">
|
||||
<div class="sphinxsidebarwrapper">
|
||||
<h1 class="logo"><a href="../../../index.html">Thun</a></h1>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h3>Navigation</h3>
|
||||
<ul>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../../notebooks/Intro.html">Thun: Joy in Python</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../../joy.html">Joy Interpreter</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../../stack.html">Stack or Quote or Sequence or List…</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../../parser.html">Parsing Text into Joy Expressions</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../../pretty.html">Tracing Joy Execution</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../../library.html">Function Reference</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../../lib.html">Functions Grouped by, er, Function with Examples</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../../types.html">Type Inference of Joy Expressions</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../../notebooks/index.html">Essays about Programming in Joy</a></li>
|
||||
</ul>
|
||||
|
||||
<div class="relations">
|
||||
<h3>Related Topics</h3>
|
||||
<ul>
|
||||
<li><a href="../../../index.html">Documentation overview</a><ul>
|
||||
|
|
@ -146,17 +200,23 @@
|
|||
</ul>
|
||||
</div>
|
||||
<div id="searchbox" style="display: none" role="search">
|
||||
<h3>Quick search</h3>
|
||||
<h3 id="searchlabel">Quick search</h3>
|
||||
<div class="searchformwrapper">
|
||||
<form class="search" action="../../../search.html" method="get">
|
||||
<input type="text" name="q" />
|
||||
<input type="text" name="q" aria-labelledby="searchlabel" />
|
||||
<input type="submit" value="Go" />
|
||||
<input type="hidden" name="check_keywords" value="yes" />
|
||||
<input type="hidden" name="area" value="default" />
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">$('#searchbox').show(0);</script>
|
||||
<script>$('#searchbox').show(0);</script>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="clearer"></div>
|
||||
|
|
@ -167,7 +227,7 @@
|
|||
</a>
|
||||
<br />
|
||||
<span xmlns:dct="http://purl.org/dc/terms/" property="dct:title">Thun Documentation</span> by <a xmlns:cc="http://creativecommons.org/ns#" href="https://joypy.osdn.io/" property="cc:attributionName" rel="cc:attributionURL">Simon Forman</a> is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/4.0/">Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License</a>.<br />Based on a work at <a xmlns:dct="http://purl.org/dc/terms/" href="https://osdn.net/projects/joypy/" rel="dct:source">https://osdn.net/projects/joypy/</a>.
|
||||
Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.7.3.
|
||||
Created using <a href="http://sphinx-doc.org/">Sphinx</a> 3.0.2.
|
||||
</div>
|
||||
|
||||
</body>
|
||||
|
|
|
|||
|
|
@ -1,19 +1,18 @@
|
|||
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<!DOCTYPE html>
|
||||
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=Edge" />
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<meta charset="utf-8" />
|
||||
<title>joy.utils.stack — Thun 0.2.0 documentation</title>
|
||||
<link rel="stylesheet" href="../../../_static/alabaster.css" type="text/css" />
|
||||
<link rel="stylesheet" href="../../../_static/pygments.css" type="text/css" />
|
||||
<script type="text/javascript" src="../../../_static/documentation_options.js"></script>
|
||||
<script type="text/javascript" src="../../../_static/jquery.js"></script>
|
||||
<script type="text/javascript" src="../../../_static/underscore.js"></script>
|
||||
<script type="text/javascript" src="../../../_static/doctools.js"></script>
|
||||
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
|
||||
<script id="documentation_options" data-url_root="../../../" src="../../../_static/documentation_options.js"></script>
|
||||
<script src="../../../_static/jquery.js"></script>
|
||||
<script src="../../../_static/underscore.js"></script>
|
||||
<script src="../../../_static/doctools.js"></script>
|
||||
<script src="../../../_static/language_data.js"></script>
|
||||
<script async="async" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/latest.js?config=TeX-AMS-MML_HTMLorMML"></script>
|
||||
<link rel="index" title="Index" href="../../../genindex.html" />
|
||||
<link rel="search" title="Search" href="../../../search.html" />
|
||||
|
||||
|
|
@ -28,6 +27,8 @@
|
|||
<div class="document">
|
||||
<div class="documentwrapper">
|
||||
<div class="bodywrapper">
|
||||
|
||||
|
||||
<div class="body" role="main">
|
||||
|
||||
<h1>Source code for joy.utils.stack</h1><div class="highlight"><pre>
|
||||
|
|
@ -105,7 +106,7 @@
|
|||
<span class="sd">'''</span>
|
||||
|
||||
|
||||
<span class="kn">from</span> <span class="nn">builtins</span> <span class="k">import</span> <span class="nb">map</span>
|
||||
<span class="kn">from</span> <span class="nn">builtins</span> <span class="kn">import</span> <span class="nb">map</span>
|
||||
<div class="viewcode-block" id="list_to_stack"><a class="viewcode-back" href="../../../stack.html#joy.utils.stack.list_to_stack">[docs]</a><span class="k">def</span> <span class="nf">list_to_stack</span><span class="p">(</span><span class="n">el</span><span class="p">,</span> <span class="n">stack</span><span class="o">=</span><span class="p">()):</span>
|
||||
<span class="sd">'''Convert a Python list (or other sequence) to a Joy stack::</span>
|
||||
|
||||
|
|
@ -231,10 +232,34 @@
|
|||
</pre></div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
|
||||
<div class="sphinxsidebarwrapper"><div class="relations">
|
||||
<div class="sphinxsidebarwrapper">
|
||||
<h1 class="logo"><a href="../../../index.html">Thun</a></h1>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h3>Navigation</h3>
|
||||
<ul>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../../notebooks/Intro.html">Thun: Joy in Python</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../../joy.html">Joy Interpreter</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../../stack.html">Stack or Quote or Sequence or List…</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../../parser.html">Parsing Text into Joy Expressions</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../../pretty.html">Tracing Joy Execution</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../../library.html">Function Reference</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../../lib.html">Functions Grouped by, er, Function with Examples</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../../types.html">Type Inference of Joy Expressions</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../../notebooks/index.html">Essays about Programming in Joy</a></li>
|
||||
</ul>
|
||||
|
||||
<div class="relations">
|
||||
<h3>Related Topics</h3>
|
||||
<ul>
|
||||
<li><a href="../../../index.html">Documentation overview</a><ul>
|
||||
|
|
@ -244,17 +269,23 @@
|
|||
</ul>
|
||||
</div>
|
||||
<div id="searchbox" style="display: none" role="search">
|
||||
<h3>Quick search</h3>
|
||||
<h3 id="searchlabel">Quick search</h3>
|
||||
<div class="searchformwrapper">
|
||||
<form class="search" action="../../../search.html" method="get">
|
||||
<input type="text" name="q" />
|
||||
<input type="text" name="q" aria-labelledby="searchlabel" />
|
||||
<input type="submit" value="Go" />
|
||||
<input type="hidden" name="check_keywords" value="yes" />
|
||||
<input type="hidden" name="area" value="default" />
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">$('#searchbox').show(0);</script>
|
||||
<script>$('#searchbox').show(0);</script>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="clearer"></div>
|
||||
|
|
@ -265,7 +296,7 @@
|
|||
</a>
|
||||
<br />
|
||||
<span xmlns:dct="http://purl.org/dc/terms/" property="dct:title">Thun Documentation</span> by <a xmlns:cc="http://creativecommons.org/ns#" href="https://joypy.osdn.io/" property="cc:attributionName" rel="cc:attributionURL">Simon Forman</a> is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/4.0/">Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License</a>.<br />Based on a work at <a xmlns:dct="http://purl.org/dc/terms/" href="https://osdn.net/projects/joypy/" rel="dct:source">https://osdn.net/projects/joypy/</a>.
|
||||
Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.7.3.
|
||||
Created using <a href="http://sphinx-doc.org/">Sphinx</a> 3.0.2.
|
||||
</div>
|
||||
|
||||
</body>
|
||||
|
|
|
|||
|
Before Width: | Height: | Size: 673 B |
|
|
@ -1,61 +1,9 @@
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@import url("basic.css");
|
||||
|
||||
/* -- page layout ----------------------------------------------------------- */
|
||||
|
||||
body {
|
||||
font-family: 'goudy old style', 'minion pro', 'bell mt', Georgia, 'Hiragino Mincho Pro', serif;
|
||||
font-family: Georgia, serif;
|
||||
font-size: 17px;
|
||||
background-color: #fff;
|
||||
color: #000;
|
||||
|
|
@ -159,7 +107,7 @@ div.sphinxsidebarwrapper p.blurb {
|
|||
|
||||
div.sphinxsidebar h3,
|
||||
div.sphinxsidebar h4 {
|
||||
font-family: 'Garamond', 'Georgia', serif;
|
||||
font-family: Georgia, serif;
|
||||
color: #444;
|
||||
font-size: 24px;
|
||||
font-weight: normal;
|
||||
|
|
@ -203,7 +151,7 @@ div.sphinxsidebar ul li.toctree-l2 > a {
|
|||
|
||||
div.sphinxsidebar input {
|
||||
border: 1px solid #CCC;
|
||||
font-family: 'goudy old style', 'minion pro', 'bell mt', Georgia, 'Hiragino Mincho Pro', serif;
|
||||
font-family: Georgia, serif;
|
||||
font-size: 1em;
|
||||
}
|
||||
|
||||
|
|
@ -218,6 +166,19 @@ div.sphinxsidebar hr {
|
|||
width: 50%;
|
||||
}
|
||||
|
||||
div.sphinxsidebar .badge {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
div.sphinxsidebar .badge:hover {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
/* To address an issue with donation coming after search */
|
||||
div.sphinxsidebar h3.donation {
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
/* -- body styles ----------------------------------------------------------- */
|
||||
|
||||
a {
|
||||
|
|
@ -236,7 +197,7 @@ div.body h3,
|
|||
div.body h4,
|
||||
div.body h5,
|
||||
div.body h6 {
|
||||
font-family: 'Garamond', 'Georgia', serif;
|
||||
font-family: Georgia, serif;
|
||||
font-weight: normal;
|
||||
margin: 30px 0px 10px 0px;
|
||||
padding: 0;
|
||||
|
|
@ -277,7 +238,7 @@ div.admonition tt.xref, div.admonition code.xref, div.admonition a tt {
|
|||
}
|
||||
|
||||
div.admonition p.admonition-title {
|
||||
font-family: 'Garamond', 'Georgia', serif;
|
||||
font-family: Georgia, serif;
|
||||
font-weight: normal;
|
||||
font-size: 24px;
|
||||
margin: 0 0 10px 0;
|
||||
|
|
@ -366,7 +327,7 @@ p.admonition-title:after {
|
|||
}
|
||||
|
||||
pre, tt, code {
|
||||
font-family: 'Consolas', 'Menlo', 'Deja Vu Sans Mono', 'Bitstream Vera Sans Mono', monospace;
|
||||
font-family: 'Consolas', 'Menlo', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', monospace;
|
||||
font-size: 0.9em;
|
||||
}
|
||||
|
||||
|
|
@ -690,4 +651,51 @@ table.docutils.citation, table.docutils.citation td, table.docutils.citation th
|
|||
-moz-box-shadow: none;
|
||||
-webkit-box-shadow: none;
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
|
||||
/* relbar */
|
||||
|
||||
.related {
|
||||
line-height: 30px;
|
||||
width: 100%;
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
|
||||
.related.top {
|
||||
border-bottom: 1px solid #EEE;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.related.bottom {
|
||||
border-top: 1px solid #EEE;
|
||||
}
|
||||
|
||||
.related ul {
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
.related li {
|
||||
display: inline;
|
||||
}
|
||||
|
||||
nav#rellinks {
|
||||
float: right;
|
||||
}
|
||||
|
||||
nav#rellinks li+li:before {
|
||||
content: "|";
|
||||
}
|
||||
|
||||
nav#breadcrumbs li+li:before {
|
||||
content: "\00BB";
|
||||
}
|
||||
|
||||
/* Hide certain items when printing */
|
||||
@media print {
|
||||
div.related {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
|
@ -4,7 +4,7 @@
|
|||
*
|
||||
* Sphinx stylesheet -- basic theme.
|
||||
*
|
||||
* :copyright: Copyright 2007-2018 by the Sphinx team, see AUTHORS.
|
||||
* :copyright: Copyright 2007-2020 by the Sphinx team, see AUTHORS.
|
||||
* :license: BSD, see LICENSE for details.
|
||||
*
|
||||
*/
|
||||
|
|
@ -81,6 +81,10 @@ div.sphinxsidebar input {
|
|||
font-size: 1em;
|
||||
}
|
||||
|
||||
div.sphinxsidebar #searchbox form.search {
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
div.sphinxsidebar #searchbox input[type="text"] {
|
||||
float: left;
|
||||
width: 80%;
|
||||
|
|
@ -227,6 +231,16 @@ a.headerlink {
|
|||
visibility: hidden;
|
||||
}
|
||||
|
||||
a.brackets:before,
|
||||
span.brackets > a:before{
|
||||
content: "[";
|
||||
}
|
||||
|
||||
a.brackets:after,
|
||||
span.brackets > a:after {
|
||||
content: "]";
|
||||
}
|
||||
|
||||
h1:hover > a.headerlink,
|
||||
h2:hover > a.headerlink,
|
||||
h3:hover > a.headerlink,
|
||||
|
|
@ -275,6 +289,12 @@ img.align-center, .figure.align-center, object.align-center {
|
|||
margin-right: auto;
|
||||
}
|
||||
|
||||
img.align-default, .figure.align-default {
|
||||
display: block;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
}
|
||||
|
||||
.align-left {
|
||||
text-align: left;
|
||||
}
|
||||
|
|
@ -283,6 +303,10 @@ img.align-center, .figure.align-center, object.align-center {
|
|||
text-align: center;
|
||||
}
|
||||
|
||||
.align-default {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.align-right {
|
||||
text-align: right;
|
||||
}
|
||||
|
|
@ -354,6 +378,11 @@ table.align-center {
|
|||
margin-right: auto;
|
||||
}
|
||||
|
||||
table.align-default {
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
}
|
||||
|
||||
table caption span.caption-number {
|
||||
font-style: italic;
|
||||
}
|
||||
|
|
@ -387,6 +416,16 @@ table.citation td {
|
|||
border-bottom: none;
|
||||
}
|
||||
|
||||
th > p:first-child,
|
||||
td > p:first-child {
|
||||
margin-top: 0px;
|
||||
}
|
||||
|
||||
th > p:last-child,
|
||||
td > p:last-child {
|
||||
margin-bottom: 0px;
|
||||
}
|
||||
|
||||
/* -- figures --------------------------------------------------------------- */
|
||||
|
||||
div.figure {
|
||||
|
|
@ -427,6 +466,13 @@ table.field-list td, table.field-list th {
|
|||
hyphens: manual;
|
||||
}
|
||||
|
||||
/* -- hlist styles ---------------------------------------------------------- */
|
||||
|
||||
table.hlist td {
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
|
||||
/* -- other body styles ----------------------------------------------------- */
|
||||
|
||||
ol.arabic {
|
||||
|
|
@ -449,11 +495,58 @@ ol.upperroman {
|
|||
list-style: upper-roman;
|
||||
}
|
||||
|
||||
li > p:first-child {
|
||||
margin-top: 0px;
|
||||
}
|
||||
|
||||
li > p:last-child {
|
||||
margin-bottom: 0px;
|
||||
}
|
||||
|
||||
dl.footnote > dt,
|
||||
dl.citation > dt {
|
||||
float: left;
|
||||
}
|
||||
|
||||
dl.footnote > dd,
|
||||
dl.citation > dd {
|
||||
margin-bottom: 0em;
|
||||
}
|
||||
|
||||
dl.footnote > dd:after,
|
||||
dl.citation > dd:after {
|
||||
content: "";
|
||||
clear: both;
|
||||
}
|
||||
|
||||
dl.field-list {
|
||||
display: grid;
|
||||
grid-template-columns: fit-content(30%) auto;
|
||||
}
|
||||
|
||||
dl.field-list > dt {
|
||||
font-weight: bold;
|
||||
word-break: break-word;
|
||||
padding-left: 0.5em;
|
||||
padding-right: 5px;
|
||||
}
|
||||
|
||||
dl.field-list > dt:after {
|
||||
content: ":";
|
||||
}
|
||||
|
||||
dl.field-list > dd {
|
||||
padding-left: 0.5em;
|
||||
margin-top: 0em;
|
||||
margin-left: 0em;
|
||||
margin-bottom: 0em;
|
||||
}
|
||||
|
||||
dl {
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
|
||||
dd p {
|
||||
dd > p:first-child {
|
||||
margin-top: 0px;
|
||||
}
|
||||
|
||||
|
|
@ -526,6 +619,12 @@ dl.glossary dt {
|
|||
font-style: oblique;
|
||||
}
|
||||
|
||||
.classifier:before {
|
||||
font-style: normal;
|
||||
margin: 0.5em;
|
||||
content: ":";
|
||||
}
|
||||
|
||||
abbr, acronym {
|
||||
border-bottom: dotted 1px;
|
||||
cursor: help;
|
||||
|
|
@ -573,6 +672,10 @@ div.code-block-caption + div > div.highlight > pre {
|
|||
margin-top: 0;
|
||||
}
|
||||
|
||||
div.doctest > div.highlight span.gp { /* gp: Generic.Prompt */
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
div.code-block-caption span.caption-number {
|
||||
padding: 0.1em 0.3em;
|
||||
font-style: italic;
|
||||
|
|
|
|||
|
Before Width: | Height: | Size: 756 B |
|
Before Width: | Height: | Size: 829 B |
|
Before Width: | Height: | Size: 641 B |
|
|
@ -4,7 +4,7 @@
|
|||
*
|
||||
* Sphinx JavaScript utilities for all documentation.
|
||||
*
|
||||
* :copyright: Copyright 2007-2018 by the Sphinx team, see AUTHORS.
|
||||
* :copyright: Copyright 2007-2020 by the Sphinx team, see AUTHORS.
|
||||
* :license: BSD, see LICENSE for details.
|
||||
*
|
||||
*/
|
||||
|
|
@ -87,14 +87,13 @@ jQuery.fn.highlightText = function(text, className) {
|
|||
node.nextSibling));
|
||||
node.nodeValue = val.substr(0, pos);
|
||||
if (isInSVG) {
|
||||
var bbox = span.getBBox();
|
||||
var rect = document.createElementNS("http://www.w3.org/2000/svg", "rect");
|
||||
rect.x.baseVal.value = bbox.x;
|
||||
var bbox = node.parentElement.getBBox();
|
||||
rect.x.baseVal.value = bbox.x;
|
||||
rect.y.baseVal.value = bbox.y;
|
||||
rect.width.baseVal.value = bbox.width;
|
||||
rect.height.baseVal.value = bbox.height;
|
||||
rect.setAttribute('class', className);
|
||||
var parentOfText = node.parentNode.parentNode;
|
||||
addItems.push({
|
||||
"parent": node.parentNode,
|
||||
"target": rect});
|
||||
|
|
@ -150,7 +149,9 @@ var Documentation = {
|
|||
this.fixFirefoxAnchorBug();
|
||||
this.highlightSearchWords();
|
||||
this.initIndexTable();
|
||||
|
||||
if (DOCUMENTATION_OPTIONS.NAVIGATION_WITH_KEYS) {
|
||||
this.initOnKeyListeners();
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
@ -282,10 +283,11 @@ var Documentation = {
|
|||
},
|
||||
|
||||
initOnKeyListeners: function() {
|
||||
$(document).keyup(function(event) {
|
||||
$(document).keydown(function(event) {
|
||||
var activeElementType = document.activeElement.tagName;
|
||||
// don't navigate when in search box or textarea
|
||||
if (activeElementType !== 'TEXTAREA' && activeElementType !== 'INPUT' && activeElementType !== 'SELECT') {
|
||||
if (activeElementType !== 'TEXTAREA' && activeElementType !== 'INPUT' && activeElementType !== 'SELECT'
|
||||
&& !event.altKey && !event.ctrlKey && !event.metaKey && !event.shiftKey) {
|
||||
switch (event.keyCode) {
|
||||
case 37: // left
|
||||
var prevHref = $('link[rel="prev"]').prop('href');
|
||||
|
|
@ -310,4 +312,4 @@ _ = Documentation.gettext;
|
|||
|
||||
$(document).ready(function() {
|
||||
Documentation.init();
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,9 +1,12 @@
|
|||
var DOCUMENTATION_OPTIONS = {
|
||||
URL_ROOT: '',
|
||||
URL_ROOT: document.getElementById("documentation_options").getAttribute('data-url_root'),
|
||||
VERSION: '0.2.0',
|
||||
LANGUAGE: 'None',
|
||||
COLLAPSE_INDEX: false,
|
||||
BUILDER: 'html',
|
||||
FILE_SUFFIX: '.html',
|
||||
LINK_SUFFIX: '.html',
|
||||
HAS_SOURCE: true,
|
||||
SOURCELINK_SUFFIX: '.txt'
|
||||
SOURCELINK_SUFFIX: '.txt',
|
||||
NAVIGATION_WITH_KEYS: false
|
||||
};
|
||||
|
Before Width: | Height: | Size: 222 B |
|
Before Width: | Height: | Size: 202 B |