From d7d61149635d938b31c39879b808b9cdb012c2a3 Mon Sep 17 00:00:00 2001 From: Simon Forman Date: Fri, 24 Apr 2020 17:21:08 -0700 Subject: [PATCH] Rebuilt some sphinx docs. --- ..._This_Implementation_of_Joy_in_Python.html | 228 +- ...0._This_Implementation_of_Joy_in_Python.md | 226 +- ...._This_Implementation_of_Joy_in_Python.rst | 226 +- docs/2._Library_Examples.html | 2316 +---------------- docs/2._Library_Examples.md | 534 +--- docs/2._Library_Examples.rst | 851 +----- docs/Trees.html | 72 +- docs/Trees.md | 4 +- docs/Trees.rst | 4 +- .../_build/html/_modules/joy/library.html | 62 +- .../Derivatives_of_Regular_Expressions.html | 2 +- .../_build/html/notebooks/Intro.html | 2 +- docs/sphinx_docs/_build/html/searchindex.js | 2 +- 13 files changed, 665 insertions(+), 3864 deletions(-) diff --git a/docs/0._This_Implementation_of_Joy_in_Python.html b/docs/0._This_Implementation_of_Joy_in_Python.html index 6bb8ac8..0a4a6eb 100644 --- a/docs/0._This_Implementation_of_Joy_in_Python.html +++ b/docs/0._This_Implementation_of_Joy_in_Python.html @@ -11854,57 +11854,56 @@ joy?
-
§ 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::
 
-When talking about Joy we use the terms "stack", "list", "sequence" and
-"aggregate" to mean the same thing: a simple datatype that permits
-certain operations such as iterating and pushing and popping values from
-(at least) one end.
+    stack := () | (item, stack)
 
-We use the venerable two-tuple recursive form of sequences 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.
+Putting some numbers onto a stack::
 
-  ()
-  (1, ())
-  (2, (1, ()))
-  (3, (2, (1, ())))
-  ...
-
-And so on.
-
-
-We have two very simple functions to build up a stack from a Python
-iterable and also to iterate through a stack and yield its items
-one-by-one in order, and two functions to generate string representations
-of stacks:
-
-  list_to_stack()
-
-  iter_stack()
-
-  expression_to_string()  (prints left-to-right)
-
-  stack_to_string()  (prints right-to-left)
-
-
-A word about the stack data structure.
+    ()
+    (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:
+For example::
 
-  def dup(stack):
-    head, tail = stack
-    return head, (head, tail)
+        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 de-structuring the
-incoming argument and assigning values to the names.  Note that Python
+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.
+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
 
@@ -12079,22 +12078,36 @@ where they would be redundant.
def joy(stack, expression, dictionary, viewer=None):
-  '''
-  Evaluate the Joy expression on the stack.
-  '''
-  while expression:
+	'''Evaluate a Joy expression on a stack.
 
-    if viewer: viewer(stack, expression)
+	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.
 
-    term, expression = expression
-    if isinstance(term, Symbol):
-      term = dictionary[term]
-      stack, expression, dictionary = term(stack, expression, dictionary)
-    else:
-      stack = term, stack
+	The viewer is a function that is called with the stack and expression
+	on every iteration, its return value is ignored.
 
-  if viewer: viewer(stack, expression)
-  return stack, expression, dictionary
+	: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
 
 
@@ -12163,19 +12176,22 @@ where they would be redundant.
-
§ Converting text to a joy expression.
+
This module exports a single function for converting text to a joy
+expression as well as a single Symbol class and a single Exception type.
 
-This module exports a single function:
+The Symbol string class is used by the interpreter to recognize literals
+by the fact that they are not Symbol objects.
 
-  text_to_expression(text)
+A crude grammar::
 
-As well as a single Symbol class and a single Exception type:
+    joy = term*
+    term = int | float | string | '[' joy ']' | symbol
 
-  ParseError
-
-When supplied with a string this function returns a Python datastructure
-that represents the Joy datastructure described by the text expression.
-Any unbalanced square brackets will raise a ParseError.
+A Joy expression is a sequence of zero or more terms.  A term is a
+literal value (integer, float, string, or Joy expression) or a function
+symbol.  Function symbols are unquoted strings and cannot contain square
+brackets.   Terms must be separated by blanks, which can be omitted
+around square brackets.
 
@@ -12216,27 +12232,27 @@ Any unbalanced square brackets will raise a ParseError.
def _parse(tokens):
-  '''
-  Return a stack/list expression of the tokens.
-  '''
-  frame = []
-  stack = []
-  for tok in tokens:
-    if tok == '[':
-      stack.append(frame)
-      frame = []
-      stack[-1].append(frame)
-    elif tok == ']':
-      try:
-        frame = stack.pop()
-      except IndexError:
-        raise ParseError('One or more extra closing brackets.')
-      frame[-1] = list_to_stack(frame[-1])
-    else:
-      frame.append(tok)
-  if stack:
-    raise ParseError('One or more unclosed brackets.')
-  return list_to_stack(frame)
+	'''
+	Return a stack/list expression of the tokens.
+	'''
+	frame = []
+	stack = []
+	for tok in tokens:
+		if tok == '[':
+			stack.append(frame)
+			frame = []
+			stack[-1].append(frame)
+		elif tok == ']':
+			try:
+				frame = stack.pop()
+			except IndexError:
+				raise ParseError('Extra closing bracket.')
+			frame[-1] = list_to_stack(frame[-1])
+		else:
+			frame.append(tok)
+	if stack:
+		raise ParseError('Unclosed bracket.')
+	return list_to_stack(frame)
 
 
@@ -12455,7 +12471,7 @@ Any unbalanced square brackets will raise a ParseError.
-
!= % & * *fraction *fraction0 + ++ - -- / < << <= <> = > >= >> ? ^ add anamorphism and app1 app2 app3 average b binary branch choice clear cleave concat cons dinfrirst dip dipd dipdd disenstacken div down_to_zero dudipd dup dupd dupdip enstacken eq first flatten floordiv gcd ge genrec getitem gt help i id ifte infra le least_fraction loop lshift lt map min mod modulus mul ne neg not nullary or over pam parse pm pop popd popdd popop pow pred primrec product quoted range range_to_zero rem remainder remove rest reverse roll< roll> rolldown rollup rshift run second select sharing shunt size sqr sqrt stack step sub succ sum swaack swap swoncat swons ternary third times truediv truthy tuck unary uncons unit unquoted unstack 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 swons take ternary third times truediv truthy tuck unary uncons unique unit unquoted unstack unswons void warranty while words x xor zip •
 
@@ -12495,10 +12511,24 @@ Any unbalanced square brackets will raise a ParseError.
-
def dip(stack, expression, dictionary):
-  (quote, (x, stack)) = stack
-  expression = x, expression
-  return stack, pushback(quote, expression), dictionary
+
@inscribe
+@combinator_effect(_COMB_NUMS(), a1, s1)
+@FunctionWrapper
+def dip(stack, expression, dictionary):
+	'''
+	The dip combinator expects a quoted program on the stack and below it
+	some item, it hoists the item into the expression and runs the program
+	on the rest of the stack.
+	::
+
+			 ... x [Q] dip
+		-------------------
+				 ... Q x
+
+	'''
+	(quote, (x, stack)) = stack
+	expression = (x, expression)
+	return stack, concat(quote, expression), dictionary
 
 
@@ -12539,28 +12569,26 @@ Any unbalanced square brackets will raise a ParseError.
-
second == rest first
-third == rest rest first
+
ii == [dip] dupdip i
+of == swap at
 product == 1 swap [*] step
-swons == swap cons
-swoncat == swap concat
 flatten == [] swap [concat] step
-unit == [] cons
 quoted == [unit] dip
 unquoted == [i] dip
 enstacken == stack [clear] dip
-disenstacken == ? [uncons ?] loop pop
 ? == dup truthy
+disenstacken == ? [uncons ?] loop pop
 dinfrirst == dip infra first
 nullary == [stack] dinfrirst
-unary == [stack [pop] dip] dinfrirst
-binary == [stack [popop] dip] dinfrirst
-ternary == [stack [popop pop] dip] 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
-cleave == [i] app2 [popd] dip
+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
@@ -12571,8 +12599,12 @@ 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
-dudipd == dup dipd
+dupdipd == dup dipd
 primrec == [i] genrec
+step_zero == 0 roll> step
+codireco == cons dip rest cons
+make_generator == [codireco] ccons
+ifte == [nullary not] dipd branch
 
 
diff --git a/docs/0._This_Implementation_of_Joy_in_Python.md b/docs/0._This_Implementation_of_Joy_in_Python.md index 1e0b8b9..cc61da8 100644 --- a/docs/0._This_Implementation_of_Joy_in_Python.md +++ b/docs/0._This_Implementation_of_Joy_in_Python.md @@ -52,57 +52,56 @@ import joy.utils.stack print inspect.getdoc(joy.utils.stack) ``` - § 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:: - When talking about Joy we use the terms "stack", "list", "sequence" and - "aggregate" to mean the same thing: a simple datatype that permits - certain operations such as iterating and pushing and popping values from - (at least) one end. + stack := () | (item, stack) - We use the venerable two-tuple recursive form of sequences 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. + Putting some numbers onto a stack:: - () - (1, ()) - (2, (1, ())) - (3, (2, (1, ()))) - ... - - And so on. - - - We have two very simple functions to build up a stack from a Python - iterable and also to iterate through a stack and yield its items - one-by-one in order, and two functions to generate string representations - of stacks: - - list_to_stack() - - iter_stack() - - expression_to_string() (prints left-to-right) - - stack_to_string() (prints right-to-left) - - - A word about the stack data structure. + () + (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: + For example:: - def dup(stack): - head, tail = stack - return head, (head, tail) + 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 de-structuring the - incoming argument and assigning values to the names. Note that Python + 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. + 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. @@ -166,22 +165,36 @@ print inspect.getsource(joy.joy.joy) ``` def joy(stack, expression, dictionary, viewer=None): - ''' - Evaluate the Joy expression on the stack. - ''' - while expression: + '''Evaluate a Joy expression on a stack. - if viewer: viewer(stack, expression) + 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. - term, expression = expression - if isinstance(term, Symbol): - term = dictionary[term] - stack, expression, dictionary = term(stack, expression, dictionary) - else: - stack = term, stack + The viewer is a function that is called with the stack and expression + on every iteration, its return value is ignored. - if viewer: viewer(stack, expression) - return stack, expression, dictionary + :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 @@ -204,19 +217,22 @@ import joy.parser print inspect.getdoc(joy.parser) ``` - § Converting text to a joy expression. + This module exports a single function for converting text to a joy + expression as well as a single Symbol class and a single Exception type. - This module exports a single function: + The Symbol string class is used by the interpreter to recognize literals + by the fact that they are not Symbol objects. - text_to_expression(text) + A crude grammar:: - As well as a single Symbol class and a single Exception type: + joy = term* + term = int | float | string | '[' joy ']' | symbol - ParseError - - When supplied with a string this function returns a Python datastructure - that represents the Joy datastructure described by the text expression. - Any unbalanced square brackets will raise a ParseError. + A Joy expression is a sequence of zero or more terms. A term is a + literal value (integer, float, string, or Joy expression) or a function + symbol. Function symbols are unquoted strings and cannot contain square + brackets. Terms must be separated by blanks, which can be omitted + around square brackets. The parser is extremely simple, the undocumented `re.Scanner` class does most of the tokenizing work and then you just build the tuple structure out of the tokens. There's no Abstract Syntax Tree or anything like that. @@ -227,27 +243,27 @@ print inspect.getsource(joy.parser._parse) ``` def _parse(tokens): - ''' - Return a stack/list expression of the tokens. - ''' - frame = [] - stack = [] - for tok in tokens: - if tok == '[': - stack.append(frame) - frame = [] - stack[-1].append(frame) - elif tok == ']': - try: - frame = stack.pop() - except IndexError: - raise ParseError('One or more extra closing brackets.') - frame[-1] = list_to_stack(frame[-1]) - else: - frame.append(tok) - if stack: - raise ParseError('One or more unclosed brackets.') - return list_to_stack(frame) + ''' + Return a stack/list expression of the tokens. + ''' + frame = [] + stack = [] + for tok in tokens: + if tok == '[': + stack.append(frame) + frame = [] + stack[-1].append(frame) + elif tok == ']': + try: + frame = stack.pop() + except IndexError: + raise ParseError('Extra closing bracket.') + frame[-1] = list_to_stack(frame[-1]) + else: + frame.append(tok) + if stack: + raise ParseError('Unclosed bracket.') + return list_to_stack(frame) @@ -325,7 +341,7 @@ import joy.library print ' '.join(sorted(joy.library.initialize())) ``` - != % & * *fraction *fraction0 + ++ - -- / < << <= <> = > >= >> ? ^ add anamorphism and app1 app2 app3 average b binary branch choice clear cleave concat cons dinfrirst dip dipd dipdd disenstacken div down_to_zero dudipd dup dupd dupdip enstacken eq first flatten floordiv gcd ge genrec getitem gt help i id ifte infra le least_fraction loop lshift lt map min mod modulus mul ne neg not nullary or over pam parse pm pop popd popdd popop pow pred primrec product quoted range range_to_zero rem remainder remove rest reverse roll< roll> rolldown rollup rshift run second select sharing shunt size sqr sqrt stack step sub succ sum swaack swap swoncat swons ternary third times truediv truthy tuck unary uncons unit unquoted unstack 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 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`: @@ -335,10 +351,24 @@ Many of the functions are defined in Python, like `dip`: print inspect.getsource(joy.library.dip) ``` + @inscribe + @combinator_effect(_COMB_NUMS(), a1, s1) + @FunctionWrapper def dip(stack, expression, dictionary): - (quote, (x, stack)) = stack - expression = x, expression - return stack, pushback(quote, expression), dictionary + ''' + The dip combinator expects a quoted program on the stack and below it + some item, it hoists the item into the expression and runs the program + on the rest of the stack. + :: + + ... x [Q] dip + ------------------- + ... Q x + + ''' + (quote, (x, stack)) = stack + expression = (x, expression) + return stack, concat(quote, expression), dictionary @@ -349,28 +379,26 @@ Some functions are defined in equations in terms of other functions. When the i print joy.library.definitions ``` - second == rest first - third == rest rest first + ii == [dip] dupdip i + of == swap at product == 1 swap [*] step - swons == swap cons - swoncat == swap concat flatten == [] swap [concat] step - unit == [] cons quoted == [unit] dip unquoted == [i] dip enstacken == stack [clear] dip - disenstacken == ? [uncons ?] loop pop ? == dup truthy + disenstacken == ? [uncons ?] loop pop dinfrirst == dip infra first nullary == [stack] dinfrirst - unary == [stack [pop] dip] dinfrirst - binary == [stack [popop] dip] dinfrirst - ternary == [stack [popop pop] dip] 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 - cleave == [i] app2 [popd] dip + 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 @@ -381,8 +409,12 @@ print joy.library.definitions anamorphism == [pop []] swap [dip swons] genrec range == [0 <=] [1 - dup] anamorphism while == swap [nullary] cons dup dipd concat loop - dudipd == dup dipd + dupdipd == dup dipd primrec == [i] genrec + step_zero == 0 roll> step + codireco == cons dip rest cons + make_generator == [codireco] ccons + ifte == [nullary not] dipd branch diff --git a/docs/0._This_Implementation_of_Joy_in_Python.rst b/docs/0._This_Implementation_of_Joy_in_Python.rst index 7515dcc..60b736c 100644 --- a/docs/0._This_Implementation_of_Joy_in_Python.rst +++ b/docs/0._This_Implementation_of_Joy_in_Python.rst @@ -77,57 +77,56 @@ tuples. .. parsed-literal:: - § 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:: - When talking about Joy we use the terms "stack", "list", "sequence" and - "aggregate" to mean the same thing: a simple datatype that permits - certain operations such as iterating and pushing and popping values from - (at least) one end. + stack := () | (item, stack) - We use the venerable two-tuple recursive form of sequences 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. + Putting some numbers onto a stack:: - () - (1, ()) - (2, (1, ())) - (3, (2, (1, ()))) - ... - - And so on. - - - We have two very simple functions to build up a stack from a Python - iterable and also to iterate through a stack and yield its items - one-by-one in order, and two functions to generate string representations - of stacks: - - list_to_stack() - - iter_stack() - - expression_to_string() (prints left-to-right) - - stack_to_string() (prints right-to-left) - - - A word about the stack data structure. + () + (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: + For example:: - def dup(stack): - head, tail = stack - return head, (head, tail) + 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 de-structuring the - incoming argument and assigning values to the names. Note that Python + 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. + 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. @@ -216,22 +215,36 @@ command.) .. parsed-literal:: def joy(stack, expression, dictionary, viewer=None): - ''' - Evaluate the Joy expression on the stack. - ''' - while expression: + '''Evaluate a Joy expression on a stack. - if viewer: viewer(stack, expression) + 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. - term, expression = expression - if isinstance(term, Symbol): - term = dictionary[term] - stack, expression, dictionary = term(stack, expression, dictionary) - else: - stack = term, stack + The viewer is a function that is called with the stack and expression + on every iteration, its return value is ignored. - if viewer: viewer(stack, expression) - return stack, expression, dictionary + :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 @@ -276,19 +289,22 @@ Parser .. parsed-literal:: - § Converting text to a joy expression. + This module exports a single function for converting text to a joy + expression as well as a single Symbol class and a single Exception type. - This module exports a single function: + The Symbol string class is used by the interpreter to recognize literals + by the fact that they are not Symbol objects. - text_to_expression(text) + A crude grammar:: - As well as a single Symbol class and a single Exception type: + joy = term* + term = int | float | string | '[' joy ']' | symbol - ParseError - - When supplied with a string this function returns a Python datastructure - that represents the Joy datastructure described by the text expression. - Any unbalanced square brackets will raise a ParseError. + A Joy expression is a sequence of zero or more terms. A term is a + literal value (integer, float, string, or Joy expression) or a function + symbol. Function symbols are unquoted strings and cannot contain square + brackets. Terms must be separated by blanks, which can be omitted + around square brackets. The parser is extremely simple, the undocumented ``re.Scanner`` class @@ -304,27 +320,27 @@ like that. .. parsed-literal:: def _parse(tokens): - ''' - Return a stack/list expression of the tokens. - ''' - frame = [] - stack = [] - for tok in tokens: - if tok == '[': - stack.append(frame) - frame = [] - stack[-1].append(frame) - elif tok == ']': - try: - frame = stack.pop() - except IndexError: - raise ParseError('One or more extra closing brackets.') - frame[-1] = list_to_stack(frame[-1]) - else: - frame.append(tok) - if stack: - raise ParseError('One or more unclosed brackets.') - return list_to_stack(frame) + ''' + Return a stack/list expression of the tokens. + ''' + frame = [] + stack = [] + for tok in tokens: + if tok == '[': + stack.append(frame) + frame = [] + stack[-1].append(frame) + elif tok == ']': + try: + frame = stack.pop() + except IndexError: + raise ParseError('Extra closing bracket.') + frame[-1] = list_to_stack(frame[-1]) + else: + frame.append(tok) + if stack: + raise ParseError('Unclosed bracket.') + return list_to_stack(frame) @@ -415,7 +431,7 @@ provide control-flow and higher-order operations. .. parsed-literal:: - != % & * *fraction *fraction0 + ++ - -- / < << <= <> = > >= >> ? ^ add anamorphism and app1 app2 app3 average b binary branch choice clear cleave concat cons dinfrirst dip dipd dipdd disenstacken div down_to_zero dudipd dup dupd dupdip enstacken eq first flatten floordiv gcd ge genrec getitem gt help i id ifte infra le least_fraction loop lshift lt map min mod modulus mul ne neg not nullary or over pam parse pm pop popd popdd popop pow pred primrec product quoted range range_to_zero rem remainder remove rest reverse roll< roll> rolldown rollup rshift run second select sharing shunt size sqr sqrt stack step sub succ sum swaack swap swoncat swons ternary third times truediv truthy tuck unary uncons unit unquoted unstack 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 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``: @@ -427,10 +443,24 @@ Many of the functions are defined in Python, like ``dip``: .. parsed-literal:: + @inscribe + @combinator_effect(_COMB_NUMS(), a1, s1) + @FunctionWrapper def dip(stack, expression, dictionary): - (quote, (x, stack)) = stack - expression = x, expression - return stack, pushback(quote, expression), dictionary + ''' + The dip combinator expects a quoted program on the stack and below it + some item, it hoists the item into the expression and runs the program + on the rest of the stack. + :: + + ... x [Q] dip + ------------------- + ... Q x + + ''' + (quote, (x, stack)) = stack + expression = (x, expression) + return stack, concat(quote, expression), dictionary @@ -446,28 +476,26 @@ continuation) and returns control to the interpreter. .. parsed-literal:: - second == rest first - third == rest rest first + ii == [dip] dupdip i + of == swap at product == 1 swap [*] step - swons == swap cons - swoncat == swap concat flatten == [] swap [concat] step - unit == [] cons quoted == [unit] dip unquoted == [i] dip enstacken == stack [clear] dip - disenstacken == ? [uncons ?] loop pop ? == dup truthy + disenstacken == ? [uncons ?] loop pop dinfrirst == dip infra first nullary == [stack] dinfrirst - unary == [stack [pop] dip] dinfrirst - binary == [stack [popop] dip] dinfrirst - ternary == [stack [popop pop] dip] 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 - cleave == [i] app2 [popd] dip + 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 @@ -478,8 +506,12 @@ continuation) and returns control to the interpreter. anamorphism == [pop []] swap [dip swons] genrec range == [0 <=] [1 - dup] anamorphism while == swap [nullary] cons dup dipd concat loop - dudipd == dup dipd + dupdipd == dup dipd primrec == [i] genrec + step_zero == 0 roll> step + codireco == cons dip rest cons + make_generator == [codireco] ccons + ifte == [nullary not] dipd branch diff --git a/docs/2._Library_Examples.html b/docs/2._Library_Examples.html index 62c49ae..2e3a9e5 100644 --- a/docs/2._Library_Examples.html +++ b/docs/2._Library_Examples.html @@ -12535,9 +12535,35 @@ div#notebook {
-
-
[4 5 6 1 2 3]
-
+
+
+---------------------------------------------------------------------------
+KeyError                                  Traceback (most recent call last)
+<ipython-input-22-15579491b615> in <module>()
+----> 1 J('[1 2 3] [4 5 6] swoncat')
+
+/home/sforman/Desktop/ArchLayer/System/source/Thun/docs/notebook_preamble.py in J(text, stack, dictionary)
+     30 
+     31 def J(text, stack=S, dictionary=D):
+---> 32     print stack_to_string(run(text, stack, dictionary)[0])
+     33 
+     34 
+
+/home/sforman/Desktop/ArchLayer/System/source/Thun/venv/local/lib/python2.7/site-packages/joy/joy.pyc in run(text, stack, dictionary, viewer)
+     77 	'''
+     78         expression = text_to_expression(text)
+---> 79         return joy(stack, expression, dictionary, viewer)
+     80 
+     81 
+
+/home/sforman/Desktop/ArchLayer/System/source/Thun/venv/local/lib/python2.7/site-packages/joy/joy.pyc in joy(stack, expression, dictionary, viewer)
+     56                 term, expression = expression
+     57                 if isinstance(term, Symbol):
+---> 58                         term = dictionary[term]
+     59                         stack, expression, dictionary = term(stack, expression, dictionary)
+     60                 else:
+
+KeyError: swoncat
@@ -12547,7 +12573,7 @@ div#notebook {
-
In [23]:
+
In [ ]:
J('[1 2 3] [4 5 6] shunt')
@@ -12557,24 +12583,6 @@ div#notebook {
 
-
-
- - -
- -
- - -
-
[6 5 4 1 2 3]
-
-
-
- -
-
-
@@ -12586,7 +12594,7 @@ div#notebook {
-
In [24]:
+
In [ ]:
J('1 [2 3] cons')
@@ -12596,28 +12604,10 @@ div#notebook {
 
-
-
- - -
- -
- - -
-
[1 2 3]
-
-
-
- -
-
-
-
In [25]:
+
In [ ]:
J('[2 3] 1 swons')
@@ -12627,28 +12617,10 @@ div#notebook {
 
-
-
- - -
- -
- - -
-
[1 2 3]
-
-
-
- -
-
-
-
In [26]:
+
In [ ]:
J('[1 2 3] uncons')
@@ -12658,24 +12630,6 @@ div#notebook {
 
-
-
- - -
- -
- - -
-
1 [2 3]
-
-
-
- -
-
-
@@ -12687,7 +12641,7 @@ div#notebook {
-
In [27]:
+
In [ ]:
J('[1 2 3 4] first')
@@ -12697,28 +12651,10 @@ div#notebook {
 
-
-
- - -
- -
- - -
-
1
-
-
-
- -
-
-
-
In [28]:
+
In [ ]:
J('[1 2 3 4] second')
@@ -12728,28 +12664,10 @@ div#notebook {
 
-
-
- - -
- -
- - -
-
2
-
-
-
- -
-
-
-
In [29]:
+
In [ ]:
J('[1 2 3 4] third')
@@ -12759,28 +12677,10 @@ div#notebook {
 
-
-
- - -
- -
- - -
-
3
-
-
-
- -
-
-
-
In [30]:
+
In [ ]:
J('[1 2 3 4] rest')
@@ -12790,24 +12690,6 @@ div#notebook {
 
-
-
- - -
- -
- - -
-
[2 3 4]
-
-
-
- -
-
-
@@ -12819,7 +12701,7 @@ div#notebook {
-
In [31]:
+
In [ ]:
J('[[1] [2 [3] 4] [5 6]] flatten')
@@ -12829,24 +12711,6 @@ div#notebook {
 
-
-
- - -
- -
- - -
-
[1 2 [3] 4 5 6]
-
-
-
- -
-
-
@@ -12859,7 +12723,7 @@ div#notebook {
-
In [32]:
+
In [ ]:
J('[10 11 12 13 14] 2 getitem')
@@ -12869,28 +12733,10 @@ div#notebook {
 
-
-
- - -
- -
- - -
-
12
-
-
-
- -
-
-
-
In [33]:
+
In [ ]:
J('[1 2 3 4] 0 at')
@@ -12900,28 +12746,10 @@ div#notebook {
 
-
-
- - -
- -
- - -
-
1
-
-
-
- -
-
-
-
In [34]:
+
In [ ]:
J('2 [1 2 3 4] of')
@@ -12931,28 +12759,10 @@ div#notebook {
 
-
-
- - -
- -
- - -
-
3
-
-
-
- -
-
-
-
In [35]:
+
In [ ]:
J('[1 2 3 4] 2 drop')
@@ -12962,28 +12772,10 @@ div#notebook {
 
-
-
- - -
- -
- - -
-
[3 4]
-
-
-
- -
-
-
-
In [36]:
+
In [ ]:
J('[1 2 3 4] 2 take')  # reverses the order
@@ -12993,24 +12785,6 @@ div#notebook {
 
-
-
- - -
- -
- - -
-
[2 1]
-
-
-
- -
-
-
@@ -13031,7 +12805,7 @@ div#notebook {
-
In [37]:
+
In [ ]:
J('[1 2 3 1 4] 1 remove')
@@ -13041,24 +12815,6 @@ div#notebook {
 
-
-
- - -
- -
- - -
-
[2 3 1 4]
-
-
-
- -
-
-
@@ -13070,7 +12826,7 @@ div#notebook {
-
In [38]:
+
In [ ]:
J('[1 2 3 4] reverse')
@@ -13080,24 +12836,6 @@ div#notebook {
 
-
-
- - -
- -
- - -
-
[4 3 2 1]
-
-
-
- -
-
-
@@ -13109,7 +12847,7 @@ div#notebook {
-
In [39]:
+
In [ ]:
J('[1 1 1 1] size')
@@ -13119,24 +12857,6 @@ div#notebook {
 
-
-
- - -
- -
- - -
-
4
-
-
-
- -
-
-
@@ -13149,7 +12869,7 @@ div#notebook {
-
In [40]:
+
In [ ]:
J('1 2 3 [4 5 6] swaack')
@@ -13159,24 +12879,6 @@ div#notebook {
 
-
-
- - -
- -
- - -
-
6 5 4 [3 2 1]
-
-
-
- -
-
-
@@ -13188,7 +12890,7 @@ div#notebook {
-
In [41]:
+
In [ ]:
J('23 9 1 choice')
@@ -13198,28 +12900,10 @@ div#notebook {
 
-
-
- - -
- -
- - -
-
9
-
-
-
- -
-
-
-
In [42]:
+
In [ ]:
J('23 9 0 choice')
@@ -13229,28 +12913,10 @@ div#notebook {
 
-
-
- - -
- -
- - -
-
23
-
-
-
- -
-
-
-
In [43]:
+
In [ ]:
J('[23 9 7] 1 select')  # select is basically getitem, should retire it?
@@ -13260,28 +12926,10 @@ div#notebook {
 
-
-
- - -
- -
- - -
-
9
-
-
-
- -
-
-
-
In [44]:
+
In [ ]:
J('[23 9 7] 0 select')
@@ -13291,24 +12939,6 @@ div#notebook {
 
-
-
- - -
- -
- - -
-
23
-
-
-
- -
-
-
@@ -13320,7 +12950,7 @@ div#notebook {
-
In [45]:
+
In [ ]:
J('[1 2 3] [6 5 4] zip')
@@ -13330,28 +12960,10 @@ div#notebook {
 
-
-
- - -
- -
- - -
-
[[6 1] [5 2] [4 3]]
-
-
-
- -
-
-
-
In [46]:
+
In [ ]:
J('[1 2 3] [6 5 4] zip [sum] map')
@@ -13361,24 +12973,6 @@ div#notebook {
 
-
-
- - -
- -
- - -
-
[7 7 7]
-
-
-
- -
-
-
@@ -13398,7 +12992,7 @@ div#notebook {
-
In [47]:
+
In [ ]:
J('23 9 +')
@@ -13408,24 +13002,6 @@ div#notebook {
 
-
-
- - -
- -
- - -
-
32
-
-
-
- -
-
-
@@ -13437,7 +13013,7 @@ div#notebook {
-
In [48]:
+
In [ ]:
J('23 9 -')
@@ -13447,24 +13023,6 @@ div#notebook {
 
-
-
- - -
- -
- - -
-
14
-
-
-
- -
-
-
@@ -13476,7 +13034,7 @@ div#notebook {
-
In [49]:
+
In [ ]:
J('23 9 *')
@@ -13486,24 +13044,6 @@ div#notebook {
 
-
-
- - -
- -
- - -
-
207
-
-
-
- -
-
-
@@ -13515,7 +13055,7 @@ div#notebook {
-
In [50]:
+
In [ ]:
J('23 9 /')
@@ -13525,28 +13065,10 @@ div#notebook {
 
-
-
- - -
- -
- - -
-
2.5555555555555554
-
-
-
- -
-
-
-
In [51]:
+
In [ ]:
J('23 -9 truediv')
@@ -13556,28 +13078,10 @@ div#notebook {
 
-
-
- - -
- -
- - -
-
-2.5555555555555554
-
-
-
- -
-
-
-
In [52]:
+
In [ ]:
J('23 9 div')
@@ -13587,28 +13091,10 @@ div#notebook {
 
-
-
- - -
- -
- - -
-
2
-
-
-
- -
-
-
-
In [53]:
+
In [ ]:
J('23 9 floordiv')
@@ -13618,28 +13104,10 @@ div#notebook {
 
-
-
- - -
- -
- - -
-
2
-
-
-
- -
-
-
-
In [54]:
+
In [ ]:
J('23 -9 div')
@@ -13649,28 +13117,10 @@ div#notebook {
 
-
-
- - -
- -
- - -
-
-3
-
-
-
- -
-
-
-
In [55]:
+
In [ ]:
J('23 -9 floordiv')
@@ -13680,24 +13130,6 @@ div#notebook {
 
-
-
- - -
- -
- - -
-
-3
-
-
-
- -
-
-
@@ -13709,7 +13141,7 @@ div#notebook {
-
In [56]:
+
In [ ]:
J('23 9 %')
@@ -13719,24 +13151,6 @@ div#notebook {
 
-
-
- - -
- -
- - -
-
5
-
-
-
- -
-
-
@@ -13748,7 +13162,7 @@ div#notebook {
-
In [57]:
+
In [ ]:
J('23 neg -5 neg')
@@ -13758,24 +13172,6 @@ div#notebook {
 
-
-
- - -
- -
- - -
-
-23 5
-
-
-
- -
-
-
@@ -13787,7 +13183,7 @@ div#notebook {
-
In [58]:
+
In [ ]:
J('2 10 pow')
@@ -13797,24 +13193,6 @@ div#notebook {
 
-
-
- - -
- -
- - -
-
1024
-
-
-
- -
-
-
@@ -13826,7 +13204,7 @@ div#notebook {
-
In [59]:
+
In [ ]:
J('23 sqr')
@@ -13836,28 +13214,10 @@ div#notebook {
 
-
-
- - -
- -
- - -
-
529
-
-
-
- -
-
-
-
In [60]:
+
In [ ]:
J('23 sqrt')
@@ -13867,24 +13227,6 @@ div#notebook {
 
-
-
- - -
- -
- - -
-
4.795831523312719
-
-
-
- -
-
-
@@ -13896,7 +13238,7 @@ div#notebook {
-
In [61]:
+
In [ ]:
J('1 ++')
@@ -13906,28 +13248,10 @@ div#notebook {
 
-
-
- - -
- -
- - -
-
2
-
-
-
- -
-
-
-
In [62]:
+
In [ ]:
J('1 --')
@@ -13937,24 +13261,6 @@ div#notebook {
 
-
-
- - -
- -
- - -
-
0
-
-
-
- -
-
-
@@ -13966,7 +13272,7 @@ div#notebook {
-
In [63]:
+
In [ ]:
J('8 1 <<')
@@ -13976,28 +13282,10 @@ div#notebook {
 
-
-
- - -
- -
- - -
-
16
-
-
-
- -
-
-
-
In [64]:
+
In [ ]:
J('8 1 >>')
@@ -14007,24 +13295,6 @@ div#notebook {
 
-
-
- - -
- -
- - -
-
4
-
-
-
- -
-
-
@@ -14036,7 +13306,7 @@ div#notebook {
-
In [65]:
+
In [ ]:
J('[1 2 3 5] average')
@@ -14046,24 +13316,6 @@ div#notebook {
 
-
-
- - -
- -
- - -
-
2.75
-
-
-
- -
-
-
@@ -14075,7 +13327,7 @@ div#notebook {
-
In [66]:
+
In [ ]:
J('5 range')
@@ -14085,28 +13337,10 @@ div#notebook {
 
-
-
- - -
- -
- - -
-
[4 3 2 1 0]
-
-
-
- -
-
-
-
In [67]:
+
In [ ]:
J('5 range_to_zero')
@@ -14116,28 +13350,10 @@ div#notebook {
 
-
-
- - -
- -
- - -
-
[0 1 2 3 4 5]
-
-
-
- -
-
-
-
In [68]:
+
In [ ]:
J('5 down_to_zero')
@@ -14147,24 +13363,6 @@ div#notebook {
 
-
-
- - -
- -
- - -
-
5 4 3 2 1 0
-
-
-
- -
-
-
@@ -14176,7 +13374,7 @@ div#notebook {
-
In [69]:
+
In [ ]:
J('[1 2 3 5] product')
@@ -14186,24 +13384,6 @@ div#notebook {
 
-
-
- - -
- -
- - -
-
30
-
-
-
- -
-
-
@@ -14215,7 +13395,7 @@ div#notebook {
-
In [70]:
+
In [ ]:
J('[1 2 3 5] sum')
@@ -14225,24 +13405,6 @@ div#notebook {
 
-
-
- - -
- -
- - -
-
11
-
-
-
- -
-
-
@@ -14254,7 +13416,7 @@ div#notebook {
-
In [71]:
+
In [ ]:
J('[1 2 3 5] min')
@@ -14264,24 +13426,6 @@ div#notebook {
 
-
-
- - -
- -
- - -
-
1
-
-
-
- -
-
-
@@ -14293,7 +13437,7 @@ div#notebook {
-
In [72]:
+
In [ ]:
J('45 30 gcd')
@@ -14303,24 +13447,6 @@ div#notebook {
 
-
-
- - -
- -
- - -
-
15
-
-
-
- -
-
-
@@ -14333,7 +13459,7 @@ div#notebook {
-
In [73]:
+
In [ ]:
J('[45 30] least_fraction')
@@ -14343,28 +13469,10 @@ div#notebook {
 
-
-
- - -
- -
- - -
-
[3 2]
-
-
-
- -
-
-
-
In [74]:
+
In [ ]:
J('[23 12] least_fraction')
@@ -14374,24 +13482,6 @@ div#notebook {
 
-
-
- - -
- -
- - -
-
[23 12]
-
-
-
- -
-
-
@@ -14412,7 +13502,7 @@ div#notebook {
-
In [75]:
+
In [ ]:
J('23 truthy')
@@ -14422,28 +13512,10 @@ div#notebook {
 
-
-
- - -
- -
- - -
-
True
-
-
-
- -
-
-
-
In [76]:
+
In [ ]:
J('[] truthy')  # Python semantics.
@@ -14453,28 +13525,10 @@ div#notebook {
 
-
-
- - -
- -
- - -
-
False
-
-
-
- -
-
-
-
In [77]:
+
In [ ]:
J('0 truthy')
@@ -14484,24 +13538,6 @@ div#notebook {
 
-
-
- - -
- -
- - -
-
False
-
-
-
- -
-
-
@@ -14515,7 +13551,7 @@ div#notebook {
-
In [78]:
+
In [ ]:
V('23 ?')
@@ -14525,32 +13561,10 @@ div#notebook {
 
-
-
- - -
- -
- - -
-
        . 23 ?
-     23 . ?
-     23 . dup truthy
-  23 23 . truthy
-23 True . 
-
-
-
- -
-
-
-
In [79]:
+
In [ ]:
J('[] ?')
@@ -14560,28 +13574,10 @@ div#notebook {
 
-
-
- - -
- -
- - -
-
[] False
-
-
-
- -
-
-
-
In [80]:
+
In [ ]:
J('0 ?')
@@ -14591,24 +13587,6 @@ div#notebook {
 
-
-
- - -
- -
- - -
-
0 False
-
-
-
- -
-
-
@@ -14620,7 +13598,7 @@ div#notebook {
-
In [81]:
+
In [ ]:
J('23 9 &')
@@ -14630,24 +13608,6 @@ div#notebook {
 
-
-
- - -
- -
- - -
-
1
-
-
-
- -
-
-
@@ -14659,7 +13619,7 @@ div#notebook {
-
In [82]:
+
In [ ]:
J('23 9 !=')
@@ -14669,24 +13629,6 @@ div#notebook {
 
-
-
- - -
- -
- - -
-
True
-
-
-
- -
-
-
@@ -14716,7 +13658,7 @@ div#notebook {
-
In [83]:
+
In [ ]:
J('1 1 ^')
@@ -14726,28 +13668,10 @@ div#notebook {
 
-
-
- - -
- -
- - -
-
0
-
-
-
- -
-
-
-
In [84]:
+
In [ ]:
J('1 0 ^')
@@ -14757,24 +13681,6 @@ div#notebook {
 
-
-
- - -
- -
- - -
-
1
-
-
-
- -
-
-
@@ -14794,7 +13700,7 @@ div#notebook {
-
In [85]:
+
In [ ]:
J('[help] help')
@@ -14804,25 +13710,6 @@ div#notebook {
 
-
-
- - -
- -
- - -
-
Accepts a quoted symbol on the top of the stack and prints its docs.
-
-
-
-
- -
-
-
@@ -14834,7 +13721,7 @@ div#notebook {
-
In [86]:
+
In [ ]:
J('[parse] help')
@@ -14844,29 +13731,10 @@ div#notebook {
 
-
-
- - -
- -
- - -
-
Parse the string on the stack to a Joy expression.
-
-
-
-
- -
-
-
-
In [87]:
+
In [ ]:
J('1 "2 [3] dup" parse')
@@ -14876,24 +13744,6 @@ div#notebook {
 
-
-
- - -
- -
- - -
-
1 [2 [3] dup]
-
-
-
- -
-
-
@@ -14906,7 +13756,7 @@ div#notebook {
-
In [88]:
+
In [ ]:
J('[1 2 dup + +] run')
@@ -14916,24 +13766,6 @@ div#notebook {
 
-
-
- - -
- -
- - -
-
[5]
-
-
-
- -
-
-
@@ -14953,7 +13785,7 @@ div#notebook {
-
In [89]:
+
In [ ]:
J('[app1] help')
@@ -14963,35 +13795,10 @@ div#notebook {
 
-
-
- - -
- -
- - -
-
Given a quoted program on TOS and anything as the second stack item run
-the program and replace the two args with the first result of the
-program.
-
-            ... x [Q] . app1
-   -----------------------------------
-      ... [x ...] [Q] . infra first
-
-
-
-
- -
-
-
-
In [90]:
+
In [ ]:
J('10 4 [sqr *] app1')
@@ -15001,28 +13808,10 @@ program.
 
-
-
- - -
- -
- - -
-
10 160
-
-
-
- -
-
-
-
In [91]:
+
In [ ]:
J('10 3 4 [sqr *] app2')
@@ -15032,28 +13821,10 @@ program.
 
-
-
- - -
- -
- - -
-
10 90 160
-
-
-
- -
-
-
-
In [92]:
+
In [ ]:
J('[app2] help')
@@ -15063,34 +13834,10 @@ program.
 
-
-
- - -
- -
- - -
-
Like app1 with two items.
-
-       ... y x [Q] . app2
------------------------------------
-   ... [y ...] [Q] . infra first
-       [x ...] [Q]   infra first
-
-
-
-
- -
-
-
-
In [93]:
+
In [ ]:
J('10 2 3 4 [sqr *] app3')
@@ -15100,24 +13847,6 @@ program.
 
-
-
- - -
- -
- - -
-
10 40 90 160
-
-
-
- -
-
-
@@ -15139,7 +13868,7 @@ program.
-
In [94]:
+
In [ ]:
J('3 [0 <=] [1 - dup] anamorphism')
@@ -15149,24 +13878,6 @@ program.
 
-
-
- - -
- -
- - -
-
[2 1 0]
-
-
-
- -
-
-
@@ -15178,7 +13889,7 @@ program.
-
In [95]:
+
In [ ]:
J('3 4 1 [+] [*] branch')
@@ -15188,28 +13899,10 @@ program.
 
-
-
- - -
- -
- - -
-
12
-
-
-
- -
-
-
-
In [96]:
+
In [ ]:
J('3 4 0 [+] [*] branch')
@@ -15219,24 +13912,6 @@ program.
 
-
-
- - -
- -
- - -
-
7
-
-
-
- -
-
-
@@ -15260,7 +13935,7 @@ results P(X) and Q(X)."

-
In [97]:
+
In [ ]:
J('10 2 [+] [-] cleave')
@@ -15270,24 +13945,6 @@ results P(X) and Q(X)."

-
-
- - -
- -
- - -
-
10 12 8
-
-
-
- -
-
-
@@ -15299,7 +13956,7 @@ results P(X) and Q(X)."

-
In [98]:
+
In [ ]:
J('1 2 3 4 5 [+] dip')
@@ -15309,28 +13966,10 @@ results P(X) and Q(X)."

-
-
- - -
- -
- - -
-
1 2 7 5
-
-
-
- -
-
-
-
In [99]:
+
In [ ]:
J('1 2 3 4 5 [+] dipd')
@@ -15340,28 +13979,10 @@ results P(X) and Q(X)."

-
-
- - -
- -
- - -
-
1 5 4 5
-
-
-
- -
-
-
-
In [100]:
+
In [ ]:
J('1 2 3 4 5 [+] dipdd')
@@ -15371,24 +13992,6 @@ results P(X) and Q(X)."

-
-
- - -
- -
- - -
-
3 3 4 5
-
-
-
- -
-
-
@@ -15403,7 +14006,7 @@ results P(X) and Q(X)."

-
In [101]:
+
In [ ]:
V('23 [++] dupdip *')  # N(N + 1)
@@ -15413,30 +14016,6 @@ results P(X) and Q(X)."

-
-
- - -
- -
- - -
-
        . 23 [++] dupdip *
-     23 . [++] dupdip *
-23 [++] . dupdip *
-     23 . ++ 23 *
-     24 . 23 *
-  24 23 . *
-    552 . 
-
-
-
- -
-
-
@@ -15448,7 +14027,7 @@ results P(X) and Q(X)."

-
In [102]:
+
In [ ]:
J('[genrec] help')
@@ -15458,72 +14037,10 @@ results P(X) and Q(X)."

-
-
- - -
- -
- - -
-
General Recursion Combinator.
-
-                        [if] [then] [rec1] [rec2] genrec
-  ---------------------------------------------------------------------
-     [if] [then] [rec1 [[if] [then] [rec1] [rec2] genrec] rec2] ifte
-
-From "Recursion Theory and Joy" (j05cmp.html) by Manfred von Thun:
-"The genrec combinator takes four program parameters in addition to
-whatever data parameters it needs. Fourth from the top is an if-part,
-followed by a then-part. If the if-part yields true, then the then-part
-is executed and the combinator terminates. The other two parameters are
-the rec1-part and the rec2-part. If the if-part yields false, the
-rec1-part is executed. Following that the four program parameters and
-the combinator are again pushed onto the stack bundled up in a quoted
-form. Then the rec2-part is executed, where it will find the bundled
-form. Typically it will then execute the bundled form, either with i or
-with app2, or some other combinator."
-
-The way to design one of these is to fix your base case [then] and the
-test [if], and then treat rec1 and rec2 as an else-part "sandwiching"
-a quotation of the whole function.
-
-For example, given a (general recursive) function 'F':
-
-    F == [I] [T] [R1] [R2] genrec
-
-If the [I] if-part fails you must derive R1 and R2 from:
-
-    ... R1 [F] R2
-
-Just set the stack arguments in front, and figure out what R1 and R2
-have to do to apply the quoted [F] in the proper way.  In effect, the
-genrec combinator turns into an ifte combinator with a quoted copy of
-the original definition in the else-part:
-
-    F == [I] [T] [R1]   [R2] genrec
-      == [I] [T] [R1 [F] R2] ifte
-
-(Primitive recursive functions are those where R2 == i.
-
-    P == [I] [T] [R] primrec
-      == [I] [T] [R [P] i] ifte
-      == [I] [T] [R P] ifte
-)
-
-
-
-
- -
-
-
-
In [103]:
+
In [ ]:
J('3 [1 <=] [] [dup --] [i *] genrec')
@@ -15533,24 +14050,6 @@ the original definition in the else-part:
 
-
-
- - -
- -
- - -
-
6
-
-
-
- -
-
-
@@ -15562,7 +14061,7 @@ the original definition in the else-part:
-
In [104]:
+
In [ ]:
V('1 2 3 [+ +] i')
@@ -15572,31 +14071,6 @@ the original definition in the else-part:
 
-
-
- - -
- -
- - -
-
            . 1 2 3 [+ +] i
-          1 . 2 3 [+ +] i
-        1 2 . 3 [+ +] i
-      1 2 3 . [+ +] i
-1 2 3 [+ +] . i
-      1 2 3 . + +
-        1 5 . +
-          6 . 
-
-
-
- -
-
-
@@ -15610,7 +14084,7 @@ the original definition in the else-part:
-
In [105]:
+
In [ ]:
J('1 2 [1] [+] [*] ifte')
@@ -15620,28 +14094,10 @@ the original definition in the else-part:
 
-
-
- - -
- -
- - -
-
3
-
-
-
- -
-
-
-
In [106]:
+
In [ ]:
J('1 2 [0] [+] [*] ifte')
@@ -15651,24 +14107,6 @@ the original definition in the else-part:
 
-
-
- - -
- -
- - -
-
2
-
-
-
- -
-
-
@@ -15680,7 +14118,7 @@ the original definition in the else-part:
-
In [107]:
+
In [ ]:
V('1 2 3 [4 5 6] [* +] infra')
@@ -15690,34 +14128,6 @@ the original definition in the else-part:
 
-
-
- - -
- -
- - -
-
                    . 1 2 3 [4 5 6] [* +] infra
-                  1 . 2 3 [4 5 6] [* +] infra
-                1 2 . 3 [4 5 6] [* +] infra
-              1 2 3 . [4 5 6] [* +] infra
-      1 2 3 [4 5 6] . [* +] infra
-1 2 3 [4 5 6] [* +] . infra
-              6 5 4 . * + [3 2 1] swaack
-               6 20 . + [3 2 1] swaack
-                 26 . [3 2 1] swaack
-         26 [3 2 1] . swaack
-         1 2 3 [26] . 
-
-
-
- -
-
-
@@ -15729,7 +14139,7 @@ the original definition in the else-part:
-
In [108]:
+
In [ ]:
J('[loop] help')
@@ -15739,37 +14149,10 @@ the original definition in the else-part:
 
-
-
- - -
- -
- - -
-
Basic loop combinator.
-
-   ... True [Q] loop
------------------------
-     ... Q [Q] loop
-
-   ... False [Q] loop
-------------------------
-          ...
-
-
-
-
- -
-
-
-
In [109]:
+
In [ ]:
V('3 dup [1 - dup] loop')
@@ -15779,43 +14162,6 @@ the original definition in the else-part:
 
-
-
- - -
- -
- - -
-
              . 3 dup [1 - dup] loop
-            3 . dup [1 - dup] loop
-          3 3 . [1 - dup] loop
-3 3 [1 - dup] . loop
-            3 . 1 - dup [1 - dup] loop
-          3 1 . - dup [1 - dup] loop
-            2 . dup [1 - dup] loop
-          2 2 . [1 - dup] loop
-2 2 [1 - dup] . loop
-            2 . 1 - dup [1 - dup] loop
-          2 1 . - dup [1 - dup] loop
-            1 . dup [1 - dup] loop
-          1 1 . [1 - dup] loop
-1 1 [1 - dup] . loop
-            1 . 1 - dup [1 - dup] loop
-          1 1 . - dup [1 - dup] loop
-            0 . dup [1 - dup] loop
-          0 0 . [1 - dup] loop
-0 0 [1 - dup] . loop
-            0 . 
-
-
-
- -
-
-
@@ -15827,7 +14173,7 @@ the original definition in the else-part:
-
In [110]:
+
In [ ]:
J('10 [1 2 3] [*] map')
@@ -15837,28 +14183,10 @@ the original definition in the else-part:
 
-
-
- - -
- -
- - -
-
10 [10 20 30]
-
-
-
- -
-
-
-
In [111]:
+
In [ ]:
J('10 5 [[*][/][+][-]] pam')
@@ -15868,24 +14196,6 @@ the original definition in the else-part:
 
-
-
- - -
- -
- - -
-
10 5 [50 2.0 15 5]
-
-
-
- -
-
-
@@ -15898,7 +14208,7 @@ the original definition in the else-part:
-
In [112]:
+
In [ ]:
J('1 2 3 4 5 [+] nullary')
@@ -15908,28 +14218,10 @@ the original definition in the else-part:
 
-
-
- - -
- -
- - -
-
1 2 3 4 5 9
-
-
-
- -
-
-
-
In [113]:
+
In [ ]:
J('1 2 3 4 5 [+] unary')
@@ -15939,28 +14231,10 @@ the original definition in the else-part:
 
-
-
- - -
- -
- - -
-
1 2 3 4 9
-
-
-
- -
-
-
-
In [114]:
+
In [ ]:
J('1 2 3 4 5 [+] binary')  # + has arity 2 so this is technically pointless...
@@ -15970,28 +14244,10 @@ the original definition in the else-part:
 
-
-
- - -
- -
- - -
-
1 2 3 9
-
-
-
- -
-
-
-
In [115]:
+
In [ ]:
J('1 2 3 4 5 [+] ternary')
@@ -16001,24 +14257,6 @@ the original definition in the else-part:
 
-
-
- - -
- -
- - -
-
1 2 9
-
-
-
- -
-
-
@@ -16030,7 +14268,7 @@ the original definition in the else-part:
-
In [116]:
+
In [ ]:
J('[step] help')
@@ -16040,46 +14278,10 @@ the original definition in the else-part:
 
-
-
- - -
- -
- - -
-
Run a quoted program on each item in a sequence.
-
-        ... [] [Q] . step
-     -----------------------
-               ... .
-
-
-       ... [a] [Q] . step
-    ------------------------
-             ... a . Q
-
-
-   ... [a b c] [Q] . step
-----------------------------------------
-             ... a . Q [b c] [Q] step
-
-The step combinator executes the quotation on each member of the list
-on top of the stack.
-
-
-
-
- -
-
-
-
In [117]:
+
In [ ]:
V('0 [1 2 3] [+] step')
@@ -16089,40 +14291,6 @@ on top of the stack.
 
-
-
- - -
- -
- - -
-
              . 0 [1 2 3] [+] step
-            0 . [1 2 3] [+] step
-    0 [1 2 3] . [+] step
-0 [1 2 3] [+] . step
-      0 1 [+] . i [2 3] [+] step
-          0 1 . + [2 3] [+] step
-            1 . [2 3] [+] step
-      1 [2 3] . [+] step
-  1 [2 3] [+] . step
-      1 2 [+] . i [3] [+] step
-          1 2 . + [3] [+] step
-            3 . [3] [+] step
-        3 [3] . [+] step
-    3 [3] [+] . step
-      3 3 [+] . i
-          3 3 . +
-            6 . 
-
-
-
- -
-
-
@@ -16134,7 +14302,7 @@ on top of the stack.
-
In [118]:
+
In [ ]:
V('3 2 1 2 [+] times')
@@ -16144,35 +14312,6 @@ on top of the stack.
 
-
-
- - -
- -
- - -
-
            . 3 2 1 2 [+] times
-          3 . 2 1 2 [+] times
-        3 2 . 1 2 [+] times
-      3 2 1 . 2 [+] times
-    3 2 1 2 . [+] times
-3 2 1 2 [+] . times
-      3 2 1 . + 1 [+] times
-        3 3 . 1 [+] times
-      3 3 1 . [+] times
-  3 3 1 [+] . times
-        3 3 . +
-          6 . 
-
-
-
- -
-
-
@@ -16184,7 +14323,7 @@ on top of the stack.
-
In [119]:
+
In [ ]:
J('[b] help')
@@ -16194,32 +14333,10 @@ on top of the stack.
 
-
-
- - -
- -
- - -
-
b == [i] dip i
-
-... [P] [Q] b == ... [P] i [Q] i
-... [P] [Q] b == ... P Q
-
-
-
-
- -
-
-
-
In [120]:
+
In [ ]:
V('1 2 [3] [4] b')
@@ -16229,31 +14346,6 @@ on top of the stack.
 
-
-
- - -
- -
- - -
-
            . 1 2 [3] [4] b
-          1 . 2 [3] [4] b
-        1 2 . [3] [4] b
-    1 2 [3] . [4] b
-1 2 [3] [4] . b
-        1 2 . 3 4
-      1 2 3 . 4
-    1 2 3 4 . 
-
-
-
- -
-
-
@@ -16267,7 +14359,7 @@ on top of the stack.
-
In [121]:
+
In [ ]:
J('3 [0 >] [dup --] while')
@@ -16277,24 +14369,6 @@ on top of the stack.
 
-
-
- - -
- -
- - -
-
3 2 1 0
-
-
-
- -
-
-
@@ -16306,7 +14380,7 @@ on top of the stack.
-
In [122]:
+
In [ ]:
J('[x] help')
@@ -16316,33 +14390,10 @@ on top of the stack.
 
-
-
- - -
- -
- - -
-
x == dup i
-
-... [Q] x = ... [Q] dup i
-... [Q] x = ... [Q] [Q] i
-... [Q] x = ... [Q]  Q
-
-
-
-
- -
-
-
-
In [123]:
+
In [ ]:
V('1 [2] [i 3] x')  # Kind of a pointless example.
@@ -16352,33 +14403,6 @@ on top of the stack.
 
-
-
- - -
- -
- - -
-
            . 1 [2] [i 3] x
-          1 . [2] [i 3] x
-      1 [2] . [i 3] x
-1 [2] [i 3] . x
-1 [2] [i 3] . i 3
-      1 [2] . i 3 3
-          1 . 2 3 3
-        1 2 . 3 3
-      1 2 3 . 3
-    1 2 3 3 . 
-
-
-
- -
-
-
@@ -16391,7 +14415,7 @@ on top of the stack.
-
In [124]:
+
In [ ]:
J('[] void')
@@ -16401,28 +14425,10 @@ on top of the stack.
 
-
-
- - -
- -
- - -
-
False
-
-
-
- -
-
-
-
In [125]:
+
In [ ]:
J('[[]] void')
@@ -16432,28 +14438,10 @@ on top of the stack.
 
-
-
- - -
- -
- - -
-
True
-
-
-
- -
-
-
-
In [126]:
+
In [ ]:
J('[[][[]]] void')
@@ -16463,28 +14451,10 @@ on top of the stack.
 
-
-
- - -
- -
- - -
-
True
-
-
-
- -
-
-
-
In [127]:
+
In [ ]:
J('[[[]][[][]]] void')
@@ -16494,24 +14464,6 @@ on top of the stack.
 
-
-
- - -
- -
- - -
-
False
-
-
-
- -
-
-
diff --git a/docs/2._Library_Examples.md b/docs/2._Library_Examples.md index fd70ce7..f891158 100644 --- a/docs/2._Library_Examples.md +++ b/docs/2._Library_Examples.md @@ -207,7 +207,40 @@ J('[1 2 3] [4 5 6] concat') J('[1 2 3] [4 5 6] swoncat') ``` - [4 5 6 1 2 3] + + --------------------------------------------------------------------------- + + KeyError Traceback (most recent call last) + + in () + ----> 1 J('[1 2 3] [4 5 6] swoncat') + + + /home/sforman/Desktop/ArchLayer/System/source/Thun/docs/notebook_preamble.py in J(text, stack, dictionary) + 30 + 31 def J(text, stack=S, dictionary=D): + ---> 32 print stack_to_string(run(text, stack, dictionary)[0]) + 33 + 34 + + + /home/sforman/Desktop/ArchLayer/System/source/Thun/venv/local/lib/python2.7/site-packages/joy/joy.pyc in run(text, stack, dictionary, viewer) + 77 ''' + 78 expression = text_to_expression(text) + ---> 79 return joy(stack, expression, dictionary, viewer) + 80 + 81 + + + /home/sforman/Desktop/ArchLayer/System/source/Thun/venv/local/lib/python2.7/site-packages/joy/joy.pyc in joy(stack, expression, dictionary, viewer) + 56 term, expression = expression + 57 if isinstance(term, Symbol): + ---> 58 term = dictionary[term] + 59 stack, expression, dictionary = term(stack, expression, dictionary) + 60 else: + + + KeyError: swoncat @@ -215,9 +248,6 @@ J('[1 2 3] [4 5 6] swoncat') J('[1 2 3] [4 5 6] shunt') ``` - [6 5 4 1 2 3] - - ### `cons` `swons` `uncons` @@ -225,25 +255,16 @@ J('[1 2 3] [4 5 6] shunt') J('1 [2 3] cons') ``` - [1 2 3] - - ```python J('[2 3] 1 swons') ``` - [1 2 3] - - ```python J('[1 2 3] uncons') ``` - 1 [2 3] - - ### `first` `second` `third` `rest` @@ -251,33 +272,21 @@ J('[1 2 3] uncons') J('[1 2 3 4] first') ``` - 1 - - ```python J('[1 2 3 4] second') ``` - 2 - - ```python J('[1 2 3 4] third') ``` - 3 - - ```python J('[1 2 3 4] rest') ``` - [2 3 4] - - ### `flatten` @@ -285,9 +294,6 @@ J('[1 2 3 4] rest') J('[[1] [2 [3] 4] [5 6]] flatten') ``` - [1 2 [3] 4 5 6] - - ### `getitem` `at` `of` `drop` `take` `at` and `getitem` are the same function. `of == swap at` @@ -297,41 +303,26 @@ J('[[1] [2 [3] 4] [5 6]] flatten') J('[10 11 12 13 14] 2 getitem') ``` - 12 - - ```python J('[1 2 3 4] 0 at') ``` - 1 - - ```python J('2 [1 2 3 4] of') ``` - 3 - - ```python J('[1 2 3 4] 2 drop') ``` - [3 4] - - ```python J('[1 2 3 4] 2 take') # reverses the order ``` - [2 1] - - `reverse` could be defines as `reverse == dup size take` ### `remove` @@ -341,9 +332,6 @@ J('[1 2 3 4] 2 take') # reverses the order J('[1 2 3 1 4] 1 remove') ``` - [2 3 1 4] - - ### `reverse` @@ -351,9 +339,6 @@ J('[1 2 3 1 4] 1 remove') J('[1 2 3 4] reverse') ``` - [4 3 2 1] - - ### `size` @@ -361,9 +346,6 @@ J('[1 2 3 4] reverse') J('[1 1 1 1] size') ``` - 4 - - ### `swaack` "Swap stack" swap the list on the top of the stack for the stack, and put the old stack on top of the new one. Think of it as a context switch. Niether of the lists/stacks change their order. @@ -372,9 +354,6 @@ J('[1 1 1 1] size') J('1 2 3 [4 5 6] swaack') ``` - 6 5 4 [3 2 1] - - ### `choice` `select` @@ -382,33 +361,21 @@ J('1 2 3 [4 5 6] swaack') J('23 9 1 choice') ``` - 9 - - ```python J('23 9 0 choice') ``` - 23 - - ```python J('[23 9 7] 1 select') # select is basically getitem, should retire it? ``` - 9 - - ```python J('[23 9 7] 0 select') ``` - 23 - - ### `zip` @@ -416,17 +383,11 @@ J('[23 9 7] 0 select') J('[1 2 3] [6 5 4] zip') ``` - [[6 1] [5 2] [4 3]] - - ```python J('[1 2 3] [6 5 4] zip [sum] map') ``` - [7 7 7] - - # Math words ### `+` `add` @@ -436,9 +397,6 @@ J('[1 2 3] [6 5 4] zip [sum] map') J('23 9 +') ``` - 32 - - ### `-` `sub` @@ -446,9 +404,6 @@ J('23 9 +') J('23 9 -') ``` - 14 - - ### `*` `mul` @@ -456,9 +411,6 @@ J('23 9 -') J('23 9 *') ``` - 207 - - ### `/` `div` `floordiv` `truediv` @@ -466,49 +418,31 @@ J('23 9 *') J('23 9 /') ``` - 2.5555555555555554 - - ```python J('23 -9 truediv') ``` - -2.5555555555555554 - - ```python J('23 9 div') ``` - 2 - - ```python J('23 9 floordiv') ``` - 2 - - ```python J('23 -9 div') ``` - -3 - - ```python J('23 -9 floordiv') ``` - -3 - - ### `%` `mod` `modulus` `rem` `remainder` @@ -516,9 +450,6 @@ J('23 -9 floordiv') J('23 9 %') ``` - 5 - - ### `neg` @@ -526,9 +457,6 @@ J('23 9 %') J('23 neg -5 neg') ``` - -23 5 - - ### pow @@ -536,9 +464,6 @@ J('23 neg -5 neg') J('2 10 pow') ``` - 1024 - - ### `sqr` `sqrt` @@ -546,17 +471,11 @@ J('2 10 pow') J('23 sqr') ``` - 529 - - ```python J('23 sqrt') ``` - 4.795831523312719 - - ### `++` `succ` `--` `pred` @@ -564,17 +483,11 @@ J('23 sqrt') J('1 ++') ``` - 2 - - ```python J('1 --') ``` - 0 - - ### `<<` `lshift` `>>` `rshift` @@ -582,17 +495,11 @@ J('1 --') J('8 1 <<') ``` - 16 - - ```python J('8 1 >>') ``` - 4 - - ### `average` @@ -600,9 +507,6 @@ J('8 1 >>') J('[1 2 3 5] average') ``` - 2.75 - - ### `range` `range_to_zero` `down_to_zero` @@ -610,25 +514,16 @@ J('[1 2 3 5] average') J('5 range') ``` - [4 3 2 1 0] - - ```python J('5 range_to_zero') ``` - [0 1 2 3 4 5] - - ```python J('5 down_to_zero') ``` - 5 4 3 2 1 0 - - ### `product` @@ -636,9 +531,6 @@ J('5 down_to_zero') J('[1 2 3 5] product') ``` - 30 - - ### `sum` @@ -646,9 +538,6 @@ J('[1 2 3 5] product') J('[1 2 3 5] sum') ``` - 11 - - ### `min` @@ -656,9 +545,6 @@ J('[1 2 3 5] sum') J('[1 2 3 5] min') ``` - 1 - - ### `gcd` @@ -666,9 +552,6 @@ J('[1 2 3 5] min') J('45 30 gcd') ``` - 15 - - ### `least_fraction` If we represent fractions as a quoted pair of integers [q d] this word reduces them to their ... least common factors or whatever. @@ -677,17 +560,11 @@ If we represent fractions as a quoted pair of integers [q d] this word reduces t J('[45 30] least_fraction') ``` - [3 2] - - ```python J('[23 12] least_fraction') ``` - [23 12] - - # Logic and Comparison ### `?` `truthy` @@ -698,25 +575,16 @@ Get the Boolean value of the item on the top of the stack. J('23 truthy') ``` - True - - ```python J('[] truthy') # Python semantics. ``` - False - - ```python J('0 truthy') ``` - False - - ? == dup truthy @@ -724,29 +592,16 @@ J('0 truthy') V('23 ?') ``` - . 23 ? - 23 . ? - 23 . dup truthy - 23 23 . truthy - 23 True . - - ```python J('[] ?') ``` - [] False - - ```python J('0 ?') ``` - 0 False - - ### `&` `and` @@ -754,9 +609,6 @@ J('0 ?') J('23 9 &') ``` - 1 - - ### `!=` `<>` `ne` @@ -764,9 +616,6 @@ J('23 9 &') J('23 9 !=') ``` - True - - The usual suspects: - `<` `lt` - `<=` `le` @@ -783,17 +632,11 @@ The usual suspects: J('1 1 ^') ``` - 0 - - ```python J('1 0 ^') ``` - 1 - - # Miscellaneous ### `help` @@ -803,10 +646,6 @@ J('1 0 ^') J('[help] help') ``` - Accepts a quoted symbol on the top of the stack and prints its docs. - - - ### `parse` @@ -814,18 +653,11 @@ J('[help] help') J('[parse] help') ``` - Parse the string on the stack to a Joy expression. - - - ```python J('1 "2 [3] dup" parse') ``` - 1 [2 [3] dup] - - ### `run` Evaluate a quoted Joy sequence. @@ -834,9 +666,6 @@ Evaluate a quoted Joy sequence. J('[1 2 dup + +] run') ``` - [5] - - # Combinators ### `app1` `app2` `app3` @@ -846,54 +675,26 @@ J('[1 2 dup + +] run') J('[app1] help') ``` - Given a quoted program on TOS and anything as the second stack item run - the program and replace the two args with the first result of the - program. - - ... x [Q] . app1 - ----------------------------------- - ... [x ...] [Q] . infra first - - - ```python J('10 4 [sqr *] app1') ``` - 10 160 - - ```python J('10 3 4 [sqr *] app2') ``` - 10 90 160 - - ```python J('[app2] help') ``` - Like app1 with two items. - - ... y x [Q] . app2 - ----------------------------------- - ... [y ...] [Q] . infra first - [x ...] [Q] infra first - - - ```python J('10 2 3 4 [sqr *] app3') ``` - 10 40 90 160 - - ### `anamorphism` Given an initial value, a predicate function `[P]`, and a generator function `[G]`, the `anamorphism` combinator creates a sequence. @@ -910,9 +711,6 @@ Example, `range`: J('3 [0 <=] [1 - dup] anamorphism') ``` - [2 1 0] - - ### `branch` @@ -920,17 +718,11 @@ J('3 [0 <=] [1 - dup] anamorphism') J('3 4 1 [+] [*] branch') ``` - 12 - - ```python J('3 4 0 [+] [*] branch') ``` - 7 - - ### `cleave` ... x [P] [Q] cleave @@ -949,9 +741,6 @@ Note that `P` and `Q` can use items from the stack freely, since the stack (belo J('10 2 [+] [-] cleave') ``` - 10 12 8 - - ### `dip` `dipd` `dipdd` @@ -959,25 +748,16 @@ J('10 2 [+] [-] cleave') J('1 2 3 4 5 [+] dip') ``` - 1 2 7 5 - - ```python J('1 2 3 4 5 [+] dipd') ``` - 1 5 4 5 - - ```python J('1 2 3 4 5 [+] dipdd') ``` - 3 3 4 5 - - ### `dupdip` Expects a quoted program `[Q]` on the stack and some item under it, `dup` the item and `dip` the quoted program under it. @@ -988,15 +768,6 @@ Expects a quoted program `[Q]` on the stack and some item under it, `dup` the it V('23 [++] dupdip *') # N(N + 1) ``` - . 23 [++] dupdip * - 23 . [++] dupdip * - 23 [++] . dupdip * - 23 . ++ 23 * - 24 . 23 * - 24 23 . * - 552 . - - ### `genrec` `primrec` @@ -1004,61 +775,11 @@ V('23 [++] dupdip *') # N(N + 1) J('[genrec] help') ``` - General Recursion Combinator. - - [if] [then] [rec1] [rec2] genrec - --------------------------------------------------------------------- - [if] [then] [rec1 [[if] [then] [rec1] [rec2] genrec] rec2] ifte - - From "Recursion Theory and Joy" (j05cmp.html) by Manfred von Thun: - "The genrec combinator takes four program parameters in addition to - whatever data parameters it needs. Fourth from the top is an if-part, - followed by a then-part. If the if-part yields true, then the then-part - is executed and the combinator terminates. The other two parameters are - the rec1-part and the rec2-part. If the if-part yields false, the - rec1-part is executed. Following that the four program parameters and - the combinator are again pushed onto the stack bundled up in a quoted - form. Then the rec2-part is executed, where it will find the bundled - form. Typically it will then execute the bundled form, either with i or - with app2, or some other combinator." - - The way to design one of these is to fix your base case [then] and the - test [if], and then treat rec1 and rec2 as an else-part "sandwiching" - a quotation of the whole function. - - For example, given a (general recursive) function 'F': - - F == [I] [T] [R1] [R2] genrec - - If the [I] if-part fails you must derive R1 and R2 from: - - ... R1 [F] R2 - - Just set the stack arguments in front, and figure out what R1 and R2 - have to do to apply the quoted [F] in the proper way. In effect, the - genrec combinator turns into an ifte combinator with a quoted copy of - the original definition in the else-part: - - F == [I] [T] [R1] [R2] genrec - == [I] [T] [R1 [F] R2] ifte - - (Primitive recursive functions are those where R2 == i. - - P == [I] [T] [R] primrec - == [I] [T] [R [P] i] ifte - == [I] [T] [R P] ifte - ) - - - ```python J('3 [1 <=] [] [dup --] [i *] genrec') ``` - 6 - - ### `i` @@ -1066,16 +787,6 @@ J('3 [1 <=] [] [dup --] [i *] genrec') V('1 2 3 [+ +] i') ``` - . 1 2 3 [+ +] i - 1 . 2 3 [+ +] i - 1 2 . 3 [+ +] i - 1 2 3 . [+ +] i - 1 2 3 [+ +] . i - 1 2 3 . + + - 1 5 . + - 6 . - - ### `ifte` [predicate] [then] [else] ifte @@ -1084,17 +795,11 @@ V('1 2 3 [+ +] i') J('1 2 [1] [+] [*] ifte') ``` - 3 - - ```python J('1 2 [0] [+] [*] ifte') ``` - 2 - - ### `infra` @@ -1102,19 +807,6 @@ J('1 2 [0] [+] [*] ifte') V('1 2 3 [4 5 6] [* +] infra') ``` - . 1 2 3 [4 5 6] [* +] infra - 1 . 2 3 [4 5 6] [* +] infra - 1 2 . 3 [4 5 6] [* +] infra - 1 2 3 . [4 5 6] [* +] infra - 1 2 3 [4 5 6] . [* +] infra - 1 2 3 [4 5 6] [* +] . infra - 6 5 4 . * + [3 2 1] swaack - 6 20 . + [3 2 1] swaack - 26 . [3 2 1] swaack - 26 [3 2 1] . swaack - 1 2 3 [26] . - - ### `loop` @@ -1122,45 +814,11 @@ V('1 2 3 [4 5 6] [* +] infra') J('[loop] help') ``` - Basic loop combinator. - - ... True [Q] loop - ----------------------- - ... Q [Q] loop - - ... False [Q] loop - ------------------------ - ... - - - ```python V('3 dup [1 - dup] loop') ``` - . 3 dup [1 - dup] loop - 3 . dup [1 - dup] loop - 3 3 . [1 - dup] loop - 3 3 [1 - dup] . loop - 3 . 1 - dup [1 - dup] loop - 3 1 . - dup [1 - dup] loop - 2 . dup [1 - dup] loop - 2 2 . [1 - dup] loop - 2 2 [1 - dup] . loop - 2 . 1 - dup [1 - dup] loop - 2 1 . - dup [1 - dup] loop - 1 . dup [1 - dup] loop - 1 1 . [1 - dup] loop - 1 1 [1 - dup] . loop - 1 . 1 - dup [1 - dup] loop - 1 1 . - dup [1 - dup] loop - 0 . dup [1 - dup] loop - 0 0 . [1 - dup] loop - 0 0 [1 - dup] . loop - 0 . - - ### `map` `pam` @@ -1168,17 +826,11 @@ V('3 dup [1 - dup] loop') J('10 [1 2 3] [*] map') ``` - 10 [10 20 30] - - ```python J('10 5 [[*][/][+][-]] pam') ``` - 10 5 [50 2.0 15 5] - - ### `nullary` `unary` `binary` `ternary` Run a quoted program enforcing [arity](https://en.wikipedia.org/wiki/Arity). @@ -1187,33 +839,21 @@ Run a quoted program enforcing [arity](https://en.wikipedia.org/wiki/Arity). J('1 2 3 4 5 [+] nullary') ``` - 1 2 3 4 5 9 - - ```python J('1 2 3 4 5 [+] unary') ``` - 1 2 3 4 9 - - ```python J('1 2 3 4 5 [+] binary') # + has arity 2 so this is technically pointless... ``` - 1 2 3 9 - - ```python J('1 2 3 4 5 [+] ternary') ``` - 1 2 9 - - ### `step` @@ -1221,51 +861,11 @@ J('1 2 3 4 5 [+] ternary') J('[step] help') ``` - Run a quoted program on each item in a sequence. - - ... [] [Q] . step - ----------------------- - ... . - - - ... [a] [Q] . step - ------------------------ - ... a . Q - - - ... [a b c] [Q] . step - ---------------------------------------- - ... a . Q [b c] [Q] step - - The step combinator executes the quotation on each member of the list - on top of the stack. - - - ```python V('0 [1 2 3] [+] step') ``` - . 0 [1 2 3] [+] step - 0 . [1 2 3] [+] step - 0 [1 2 3] . [+] step - 0 [1 2 3] [+] . step - 0 1 [+] . i [2 3] [+] step - 0 1 . + [2 3] [+] step - 1 . [2 3] [+] step - 1 [2 3] . [+] step - 1 [2 3] [+] . step - 1 2 [+] . i [3] [+] step - 1 2 . + [3] [+] step - 3 . [3] [+] step - 3 [3] . [+] step - 3 [3] [+] . step - 3 3 [+] . i - 3 3 . + - 6 . - - ### `times` @@ -1273,20 +873,6 @@ V('0 [1 2 3] [+] step') V('3 2 1 2 [+] times') ``` - . 3 2 1 2 [+] times - 3 . 2 1 2 [+] times - 3 2 . 1 2 [+] times - 3 2 1 . 2 [+] times - 3 2 1 2 . [+] times - 3 2 1 2 [+] . times - 3 2 1 . + 1 [+] times - 3 3 . 1 [+] times - 3 3 1 . [+] times - 3 3 1 [+] . times - 3 3 . + - 6 . - - ### `b` @@ -1294,28 +880,11 @@ V('3 2 1 2 [+] times') J('[b] help') ``` - b == [i] dip i - - ... [P] [Q] b == ... [P] i [Q] i - ... [P] [Q] b == ... P Q - - - ```python V('1 2 [3] [4] b') ``` - . 1 2 [3] [4] b - 1 . 2 [3] [4] b - 1 2 . [3] [4] b - 1 2 [3] . [4] b - 1 2 [3] [4] . b - 1 2 . 3 4 - 1 2 3 . 4 - 1 2 3 4 . - - ### `while` [predicate] [body] while @@ -1324,9 +893,6 @@ V('1 2 [3] [4] b') J('3 [0 >] [dup --] while') ``` - 3 2 1 0 - - ### `x` @@ -1334,31 +900,11 @@ J('3 [0 >] [dup --] while') J('[x] help') ``` - x == dup i - - ... [Q] x = ... [Q] dup i - ... [Q] x = ... [Q] [Q] i - ... [Q] x = ... [Q] Q - - - ```python V('1 [2] [i 3] x') # Kind of a pointless example. ``` - . 1 [2] [i 3] x - 1 . [2] [i 3] x - 1 [2] . [i 3] x - 1 [2] [i 3] . x - 1 [2] [i 3] . i 3 - 1 [2] . i 3 3 - 1 . 2 3 3 - 1 2 . 3 3 - 1 2 3 . 3 - 1 2 3 3 . - - # `void` Implements [**Laws of Form** *arithmetic*](https://en.wikipedia.org/wiki/Laws_of_Form#The_primary_arithmetic_.28Chapter_4.29) over quote-only datastructures (that is, datastructures that consist soley of containers, without strings or numbers or anything else.) @@ -1367,29 +913,17 @@ Implements [**Laws of Form** *arithmetic*](https://en.wikipedia.org/wiki/Laws_of J('[] void') ``` - False - - ```python J('[[]] void') ``` - True - - ```python J('[[][[]]] void') ``` - True - - ```python J('[[[]][[][]]] void') ``` - - False - diff --git a/docs/2._Library_Examples.rst b/docs/2._Library_Examples.rst index fe7bbb4..76361fc 100644 --- a/docs/2._Library_Examples.rst +++ b/docs/2._Library_Examples.rst @@ -268,21 +268,48 @@ List words J('[1 2 3] [4 5 6] swoncat') -.. parsed-literal:: +:: - [4 5 6 1 2 3] + + --------------------------------------------------------------------------- + + KeyError Traceback (most recent call last) + + in () + ----> 1 J('[1 2 3] [4 5 6] swoncat') + + + /home/sforman/Desktop/ArchLayer/System/source/Thun/docs/notebook_preamble.py in J(text, stack, dictionary) + 30 + 31 def J(text, stack=S, dictionary=D): + ---> 32 print stack_to_string(run(text, stack, dictionary)[0]) + 33 + 34 + + + /home/sforman/Desktop/ArchLayer/System/source/Thun/venv/local/lib/python2.7/site-packages/joy/joy.pyc in run(text, stack, dictionary, viewer) + 77 ''' + 78 expression = text_to_expression(text) + ---> 79 return joy(stack, expression, dictionary, viewer) + 80 + 81 + + + /home/sforman/Desktop/ArchLayer/System/source/Thun/venv/local/lib/python2.7/site-packages/joy/joy.pyc in joy(stack, expression, dictionary, viewer) + 56 term, expression = expression + 57 if isinstance(term, Symbol): + ---> 58 term = dictionary[term] + 59 stack, expression, dictionary = term(stack, expression, dictionary) + 60 else: + + + KeyError: swoncat .. code:: ipython2 J('[1 2 3] [4 5 6] shunt') - -.. parsed-literal:: - - [6 5 4 1 2 3] - - ``cons`` ``swons`` ``uncons`` ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -290,32 +317,14 @@ List words J('1 [2 3] cons') - -.. parsed-literal:: - - [1 2 3] - - .. code:: ipython2 J('[2 3] 1 swons') - -.. parsed-literal:: - - [1 2 3] - - .. code:: ipython2 J('[1 2 3] uncons') - -.. parsed-literal:: - - 1 [2 3] - - ``first`` ``second`` ``third`` ``rest`` ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -323,42 +332,18 @@ List words J('[1 2 3 4] first') - -.. parsed-literal:: - - 1 - - .. code:: ipython2 J('[1 2 3 4] second') - -.. parsed-literal:: - - 2 - - .. code:: ipython2 J('[1 2 3 4] third') - -.. parsed-literal:: - - 3 - - .. code:: ipython2 J('[1 2 3 4] rest') - -.. parsed-literal:: - - [2 3 4] - - ``flatten`` ~~~~~~~~~~~ @@ -366,12 +351,6 @@ List words J('[[1] [2 [3] 4] [5 6]] flatten') - -.. parsed-literal:: - - [1 2 [3] 4 5 6] - - ``getitem`` ``at`` ``of`` ``drop`` ``take`` ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -381,52 +360,22 @@ List words J('[10 11 12 13 14] 2 getitem') - -.. parsed-literal:: - - 12 - - .. code:: ipython2 J('[1 2 3 4] 0 at') - -.. parsed-literal:: - - 1 - - .. code:: ipython2 J('2 [1 2 3 4] of') - -.. parsed-literal:: - - 3 - - .. code:: ipython2 J('[1 2 3 4] 2 drop') - -.. parsed-literal:: - - [3 4] - - .. code:: ipython2 J('[1 2 3 4] 2 take') # reverses the order - -.. parsed-literal:: - - [2 1] - - ``reverse`` could be defines as ``reverse == dup size take`` ``remove`` @@ -436,12 +385,6 @@ List words J('[1 2 3 1 4] 1 remove') - -.. parsed-literal:: - - [2 3 1 4] - - ``reverse`` ~~~~~~~~~~~ @@ -449,12 +392,6 @@ List words J('[1 2 3 4] reverse') - -.. parsed-literal:: - - [4 3 2 1] - - ``size`` ~~~~~~~~ @@ -462,12 +399,6 @@ List words J('[1 1 1 1] size') - -.. parsed-literal:: - - 4 - - ``swaack`` ~~~~~~~~~~ @@ -479,12 +410,6 @@ switch. Niether of the lists/stacks change their order. J('1 2 3 [4 5 6] swaack') - -.. parsed-literal:: - - 6 5 4 [3 2 1] - - ``choice`` ``select`` ~~~~~~~~~~~~~~~~~~~~~ @@ -492,42 +417,18 @@ switch. Niether of the lists/stacks change their order. J('23 9 1 choice') - -.. parsed-literal:: - - 9 - - .. code:: ipython2 J('23 9 0 choice') - -.. parsed-literal:: - - 23 - - .. code:: ipython2 J('[23 9 7] 1 select') # select is basically getitem, should retire it? - -.. parsed-literal:: - - 9 - - .. code:: ipython2 J('[23 9 7] 0 select') - -.. parsed-literal:: - - 23 - - ``zip`` ~~~~~~~ @@ -535,22 +436,10 @@ switch. Niether of the lists/stacks change their order. J('[1 2 3] [6 5 4] zip') - -.. parsed-literal:: - - [[6 1] [5 2] [4 3]] - - .. code:: ipython2 J('[1 2 3] [6 5 4] zip [sum] map') - -.. parsed-literal:: - - [7 7 7] - - Math words ========== @@ -561,12 +450,6 @@ Math words J('23 9 +') - -.. parsed-literal:: - - 32 - - ``-`` ``sub`` ~~~~~~~~~~~~~ @@ -574,12 +457,6 @@ Math words J('23 9 -') - -.. parsed-literal:: - - 14 - - ``*`` ``mul`` ~~~~~~~~~~~~~ @@ -587,12 +464,6 @@ Math words J('23 9 *') - -.. parsed-literal:: - - 207 - - ``/`` ``div`` ``floordiv`` ``truediv`` ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -600,62 +471,26 @@ Math words J('23 9 /') - -.. parsed-literal:: - - 2.5555555555555554 - - .. code:: ipython2 J('23 -9 truediv') - -.. parsed-literal:: - - -2.5555555555555554 - - .. code:: ipython2 J('23 9 div') - -.. parsed-literal:: - - 2 - - .. code:: ipython2 J('23 9 floordiv') - -.. parsed-literal:: - - 2 - - .. code:: ipython2 J('23 -9 div') - -.. parsed-literal:: - - -3 - - .. code:: ipython2 J('23 -9 floordiv') - -.. parsed-literal:: - - -3 - - ``%`` ``mod`` ``modulus`` ``rem`` ``remainder`` ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -663,12 +498,6 @@ Math words J('23 9 %') - -.. parsed-literal:: - - 5 - - ``neg`` ~~~~~~~ @@ -676,12 +505,6 @@ Math words J('23 neg -5 neg') - -.. parsed-literal:: - - -23 5 - - pow ~~~ @@ -689,12 +512,6 @@ pow J('2 10 pow') - -.. parsed-literal:: - - 1024 - - ``sqr`` ``sqrt`` ~~~~~~~~~~~~~~~~ @@ -702,22 +519,10 @@ pow J('23 sqr') - -.. parsed-literal:: - - 529 - - .. code:: ipython2 J('23 sqrt') - -.. parsed-literal:: - - 4.795831523312719 - - ``++`` ``succ`` ``--`` ``pred`` ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -725,22 +530,10 @@ pow J('1 ++') - -.. parsed-literal:: - - 2 - - .. code:: ipython2 J('1 --') - -.. parsed-literal:: - - 0 - - ``<<`` ``lshift`` ``>>`` ``rshift`` ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -748,22 +541,10 @@ pow J('8 1 <<') - -.. parsed-literal:: - - 16 - - .. code:: ipython2 J('8 1 >>') - -.. parsed-literal:: - - 4 - - ``average`` ~~~~~~~~~~~ @@ -771,12 +552,6 @@ pow J('[1 2 3 5] average') - -.. parsed-literal:: - - 2.75 - - ``range`` ``range_to_zero`` ``down_to_zero`` ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -784,32 +559,14 @@ pow J('5 range') - -.. parsed-literal:: - - [4 3 2 1 0] - - .. code:: ipython2 J('5 range_to_zero') - -.. parsed-literal:: - - [0 1 2 3 4 5] - - .. code:: ipython2 J('5 down_to_zero') - -.. parsed-literal:: - - 5 4 3 2 1 0 - - ``product`` ~~~~~~~~~~~ @@ -817,12 +574,6 @@ pow J('[1 2 3 5] product') - -.. parsed-literal:: - - 30 - - ``sum`` ~~~~~~~ @@ -830,12 +581,6 @@ pow J('[1 2 3 5] sum') - -.. parsed-literal:: - - 11 - - ``min`` ~~~~~~~ @@ -843,12 +588,6 @@ pow J('[1 2 3 5] min') - -.. parsed-literal:: - - 1 - - ``gcd`` ~~~~~~~ @@ -856,12 +595,6 @@ pow J('45 30 gcd') - -.. parsed-literal:: - - 15 - - ``least_fraction`` ~~~~~~~~~~~~~~~~~~ @@ -872,22 +605,10 @@ reduces them to their ... least common factors or whatever. J('[45 30] least_fraction') - -.. parsed-literal:: - - [3 2] - - .. code:: ipython2 J('[23 12] least_fraction') - -.. parsed-literal:: - - [23 12] - - Logic and Comparison ==================== @@ -900,32 +621,14 @@ Get the Boolean value of the item on the top of the stack. J('23 truthy') - -.. parsed-literal:: - - True - - .. code:: ipython2 J('[] truthy') # Python semantics. - -.. parsed-literal:: - - False - - .. code:: ipython2 J('0 truthy') - -.. parsed-literal:: - - False - - :: ? == dup truthy @@ -934,36 +637,14 @@ Get the Boolean value of the item on the top of the stack. V('23 ?') - -.. parsed-literal:: - - . 23 ? - 23 . ? - 23 . dup truthy - 23 23 . truthy - 23 True . - - .. code:: ipython2 J('[] ?') - -.. parsed-literal:: - - [] False - - .. code:: ipython2 J('0 ?') - -.. parsed-literal:: - - 0 False - - ``&`` ``and`` ~~~~~~~~~~~~~ @@ -971,12 +652,6 @@ Get the Boolean value of the item on the top of the stack. J('23 9 &') - -.. parsed-literal:: - - 1 - - ``!=`` ``<>`` ``ne`` ~~~~~~~~~~~~~~~~~~~~ @@ -984,12 +659,6 @@ Get the Boolean value of the item on the top of the stack. J('23 9 !=') - -.. parsed-literal:: - - True - - | The usual suspects: - ``<`` ``lt`` - ``<=`` ``le`` | - ``=`` ``eq`` - ``>`` ``gt`` - ``>=`` ``ge`` - ``not`` - ``or`` @@ -1000,22 +669,10 @@ Get the Boolean value of the item on the top of the stack. J('1 1 ^') - -.. parsed-literal:: - - 0 - - .. code:: ipython2 J('1 0 ^') - -.. parsed-literal:: - - 1 - - Miscellaneous ============= @@ -1026,13 +683,6 @@ Miscellaneous J('[help] help') - -.. parsed-literal:: - - Accepts a quoted symbol on the top of the stack and prints its docs. - - - ``parse`` ~~~~~~~~~ @@ -1040,23 +690,10 @@ Miscellaneous J('[parse] help') - -.. parsed-literal:: - - Parse the string on the stack to a Joy expression. - - - .. code:: ipython2 J('1 "2 [3] dup" parse') - -.. parsed-literal:: - - 1 [2 [3] dup] - - ``run`` ~~~~~~~ @@ -1066,12 +703,6 @@ Evaluate a quoted Joy sequence. J('[1 2 dup + +] run') - -.. parsed-literal:: - - [5] - - Combinators =========== @@ -1082,65 +713,22 @@ Combinators J('[app1] help') - -.. parsed-literal:: - - Given a quoted program on TOS and anything as the second stack item run - the program and replace the two args with the first result of the - program. - - ... x [Q] . app1 - ----------------------------------- - ... [x ...] [Q] . infra first - - - .. code:: ipython2 J('10 4 [sqr *] app1') - -.. parsed-literal:: - - 10 160 - - .. code:: ipython2 J('10 3 4 [sqr *] app2') - -.. parsed-literal:: - - 10 90 160 - - .. code:: ipython2 J('[app2] help') - -.. parsed-literal:: - - Like app1 with two items. - - ... y x [Q] . app2 - ----------------------------------- - ... [y ...] [Q] . infra first - [x ...] [Q] infra first - - - .. code:: ipython2 J('10 2 3 4 [sqr *] app3') - -.. parsed-literal:: - - 10 40 90 160 - - ``anamorphism`` ~~~~~~~~~~~~~~~ @@ -1163,12 +751,6 @@ Example, ``range``: J('3 [0 <=] [1 - dup] anamorphism') - -.. parsed-literal:: - - [2 1 0] - - ``branch`` ~~~~~~~~~~ @@ -1176,22 +758,10 @@ Example, ``range``: J('3 4 1 [+] [*] branch') - -.. parsed-literal:: - - 12 - - .. code:: ipython2 J('3 4 0 [+] [*] branch') - -.. parsed-literal:: - - 7 - - ``cleave`` ~~~~~~~~~~ @@ -1221,12 +791,6 @@ in terms of ``app2``: J('10 2 [+] [-] cleave') - -.. parsed-literal:: - - 10 12 8 - - ``dip`` ``dipd`` ``dipdd`` ~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -1234,32 +798,14 @@ in terms of ``app2``: J('1 2 3 4 5 [+] dip') - -.. parsed-literal:: - - 1 2 7 5 - - .. code:: ipython2 J('1 2 3 4 5 [+] dipd') - -.. parsed-literal:: - - 1 5 4 5 - - .. code:: ipython2 J('1 2 3 4 5 [+] dipdd') - -.. parsed-literal:: - - 3 3 4 5 - - ``dupdip`` ~~~~~~~~~~ @@ -1274,18 +820,6 @@ Expects a quoted program ``[Q]`` on the stack and some item under it, V('23 [++] dupdip *') # N(N + 1) - -.. parsed-literal:: - - . 23 [++] dupdip * - 23 . [++] dupdip * - 23 [++] . dupdip * - 23 . ++ 23 * - 24 . 23 * - 24 23 . * - 552 . - - ``genrec`` ``primrec`` ~~~~~~~~~~~~~~~~~~~~~~ @@ -1293,66 +827,10 @@ Expects a quoted program ``[Q]`` on the stack and some item under it, J('[genrec] help') - -.. parsed-literal:: - - General Recursion Combinator. - - [if] [then] [rec1] [rec2] genrec - --------------------------------------------------------------------- - [if] [then] [rec1 [[if] [then] [rec1] [rec2] genrec] rec2] ifte - - From "Recursion Theory and Joy" (j05cmp.html) by Manfred von Thun: - "The genrec combinator takes four program parameters in addition to - whatever data parameters it needs. Fourth from the top is an if-part, - followed by a then-part. If the if-part yields true, then the then-part - is executed and the combinator terminates. The other two parameters are - the rec1-part and the rec2-part. If the if-part yields false, the - rec1-part is executed. Following that the four program parameters and - the combinator are again pushed onto the stack bundled up in a quoted - form. Then the rec2-part is executed, where it will find the bundled - form. Typically it will then execute the bundled form, either with i or - with app2, or some other combinator." - - The way to design one of these is to fix your base case [then] and the - test [if], and then treat rec1 and rec2 as an else-part "sandwiching" - a quotation of the whole function. - - For example, given a (general recursive) function 'F': - - F == [I] [T] [R1] [R2] genrec - - If the [I] if-part fails you must derive R1 and R2 from: - - ... R1 [F] R2 - - Just set the stack arguments in front, and figure out what R1 and R2 - have to do to apply the quoted [F] in the proper way. In effect, the - genrec combinator turns into an ifte combinator with a quoted copy of - the original definition in the else-part: - - F == [I] [T] [R1] [R2] genrec - == [I] [T] [R1 [F] R2] ifte - - (Primitive recursive functions are those where R2 == i. - - P == [I] [T] [R] primrec - == [I] [T] [R [P] i] ifte - == [I] [T] [R P] ifte - ) - - - .. code:: ipython2 J('3 [1 <=] [] [dup --] [i *] genrec') - -.. parsed-literal:: - - 6 - - ``i`` ~~~~~ @@ -1360,19 +838,6 @@ Expects a quoted program ``[Q]`` on the stack and some item under it, V('1 2 3 [+ +] i') - -.. parsed-literal:: - - . 1 2 3 [+ +] i - 1 . 2 3 [+ +] i - 1 2 . 3 [+ +] i - 1 2 3 . [+ +] i - 1 2 3 [+ +] . i - 1 2 3 . + + - 1 5 . + - 6 . - - ``ifte`` ~~~~~~~~ @@ -1384,22 +849,10 @@ Expects a quoted program ``[Q]`` on the stack and some item under it, J('1 2 [1] [+] [*] ifte') - -.. parsed-literal:: - - 3 - - .. code:: ipython2 J('1 2 [0] [+] [*] ifte') - -.. parsed-literal:: - - 2 - - ``infra`` ~~~~~~~~~ @@ -1407,22 +860,6 @@ Expects a quoted program ``[Q]`` on the stack and some item under it, V('1 2 3 [4 5 6] [* +] infra') - -.. parsed-literal:: - - . 1 2 3 [4 5 6] [* +] infra - 1 . 2 3 [4 5 6] [* +] infra - 1 2 . 3 [4 5 6] [* +] infra - 1 2 3 . [4 5 6] [* +] infra - 1 2 3 [4 5 6] . [* +] infra - 1 2 3 [4 5 6] [* +] . infra - 6 5 4 . * + [3 2 1] swaack - 6 20 . + [3 2 1] swaack - 26 . [3 2 1] swaack - 26 [3 2 1] . swaack - 1 2 3 [26] . - - ``loop`` ~~~~~~~~ @@ -1430,50 +867,10 @@ Expects a quoted program ``[Q]`` on the stack and some item under it, J('[loop] help') - -.. parsed-literal:: - - Basic loop combinator. - - ... True [Q] loop - ----------------------- - ... Q [Q] loop - - ... False [Q] loop - ------------------------ - ... - - - .. code:: ipython2 V('3 dup [1 - dup] loop') - -.. parsed-literal:: - - . 3 dup [1 - dup] loop - 3 . dup [1 - dup] loop - 3 3 . [1 - dup] loop - 3 3 [1 - dup] . loop - 3 . 1 - dup [1 - dup] loop - 3 1 . - dup [1 - dup] loop - 2 . dup [1 - dup] loop - 2 2 . [1 - dup] loop - 2 2 [1 - dup] . loop - 2 . 1 - dup [1 - dup] loop - 2 1 . - dup [1 - dup] loop - 1 . dup [1 - dup] loop - 1 1 . [1 - dup] loop - 1 1 [1 - dup] . loop - 1 . 1 - dup [1 - dup] loop - 1 1 . - dup [1 - dup] loop - 0 . dup [1 - dup] loop - 0 0 . [1 - dup] loop - 0 0 [1 - dup] . loop - 0 . - - ``map`` ``pam`` ~~~~~~~~~~~~~~~ @@ -1481,22 +878,10 @@ Expects a quoted program ``[Q]`` on the stack and some item under it, J('10 [1 2 3] [*] map') - -.. parsed-literal:: - - 10 [10 20 30] - - .. code:: ipython2 J('10 5 [[*][/][+][-]] pam') - -.. parsed-literal:: - - 10 5 [50 2.0 15 5] - - ``nullary`` ``unary`` ``binary`` ``ternary`` ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -1507,42 +892,18 @@ Run a quoted program enforcing J('1 2 3 4 5 [+] nullary') - -.. parsed-literal:: - - 1 2 3 4 5 9 - - .. code:: ipython2 J('1 2 3 4 5 [+] unary') - -.. parsed-literal:: - - 1 2 3 4 9 - - .. code:: ipython2 J('1 2 3 4 5 [+] binary') # + has arity 2 so this is technically pointless... - -.. parsed-literal:: - - 1 2 3 9 - - .. code:: ipython2 J('1 2 3 4 5 [+] ternary') - -.. parsed-literal:: - - 1 2 9 - - ``step`` ~~~~~~~~ @@ -1550,56 +911,10 @@ Run a quoted program enforcing J('[step] help') - -.. parsed-literal:: - - Run a quoted program on each item in a sequence. - - ... [] [Q] . step - ----------------------- - ... . - - - ... [a] [Q] . step - ------------------------ - ... a . Q - - - ... [a b c] [Q] . step - ---------------------------------------- - ... a . Q [b c] [Q] step - - The step combinator executes the quotation on each member of the list - on top of the stack. - - - .. code:: ipython2 V('0 [1 2 3] [+] step') - -.. parsed-literal:: - - . 0 [1 2 3] [+] step - 0 . [1 2 3] [+] step - 0 [1 2 3] . [+] step - 0 [1 2 3] [+] . step - 0 1 [+] . i [2 3] [+] step - 0 1 . + [2 3] [+] step - 1 . [2 3] [+] step - 1 [2 3] . [+] step - 1 [2 3] [+] . step - 1 2 [+] . i [3] [+] step - 1 2 . + [3] [+] step - 3 . [3] [+] step - 3 [3] . [+] step - 3 [3] [+] . step - 3 3 [+] . i - 3 3 . + - 6 . - - ``times`` ~~~~~~~~~ @@ -1607,23 +922,6 @@ Run a quoted program enforcing V('3 2 1 2 [+] times') - -.. parsed-literal:: - - . 3 2 1 2 [+] times - 3 . 2 1 2 [+] times - 3 2 . 1 2 [+] times - 3 2 1 . 2 [+] times - 3 2 1 2 . [+] times - 3 2 1 2 [+] . times - 3 2 1 . + 1 [+] times - 3 3 . 1 [+] times - 3 3 1 . [+] times - 3 3 1 [+] . times - 3 3 . + - 6 . - - ``b`` ~~~~~ @@ -1631,33 +929,10 @@ Run a quoted program enforcing J('[b] help') - -.. parsed-literal:: - - b == [i] dip i - - ... [P] [Q] b == ... [P] i [Q] i - ... [P] [Q] b == ... P Q - - - .. code:: ipython2 V('1 2 [3] [4] b') - -.. parsed-literal:: - - . 1 2 [3] [4] b - 1 . 2 [3] [4] b - 1 2 . [3] [4] b - 1 2 [3] . [4] b - 1 2 [3] [4] . b - 1 2 . 3 4 - 1 2 3 . 4 - 1 2 3 4 . - - ``while`` ~~~~~~~~~ @@ -1669,12 +944,6 @@ Run a quoted program enforcing J('3 [0 >] [dup --] while') - -.. parsed-literal:: - - 3 2 1 0 - - ``x`` ~~~~~ @@ -1682,36 +951,10 @@ Run a quoted program enforcing J('[x] help') - -.. parsed-literal:: - - x == dup i - - ... [Q] x = ... [Q] dup i - ... [Q] x = ... [Q] [Q] i - ... [Q] x = ... [Q] Q - - - .. code:: ipython2 V('1 [2] [i 3] x') # Kind of a pointless example. - -.. parsed-literal:: - - . 1 [2] [i 3] x - 1 . [2] [i 3] x - 1 [2] . [i 3] x - 1 [2] [i 3] . x - 1 [2] [i 3] . i 3 - 1 [2] . i 3 3 - 1 . 2 3 3 - 1 2 . 3 3 - 1 2 3 . 3 - 1 2 3 3 . - - ``void`` ======== @@ -1724,38 +967,14 @@ soley of containers, without strings or numbers or anything else.) J('[] void') - -.. parsed-literal:: - - False - - .. code:: ipython2 J('[[]] void') - -.. parsed-literal:: - - True - - .. code:: ipython2 J('[[][[]]] void') - -.. parsed-literal:: - - True - - .. code:: ipython2 J('[[[]][[][]]] void') - - -.. parsed-literal:: - - False - diff --git a/docs/Trees.html b/docs/Trees.html index 2e6ba94..893bd07 100644 --- a/docs/Trees.html +++ b/docs/Trees.html @@ -11920,7 +11920,7 @@ key left-keys right-keys
-
In [6]:
+
In [1]:
from notebook_preamble import D, J, V, define, DefinitionWrapper
@@ -13008,11 +13008,11 @@ E == pop swap roll< rest rest cons cons
 
-
In [11]:
+
In [30]:
from joy.library import FunctionWrapper
-from joy.utils.stack import pushback
+from joy.utils.stack import concat
 from notebook_preamble import D
 
 
@@ -13035,7 +13035,7 @@ E == pop swap roll< rest rest cons cons
                         L
     '''
     L, (E, (G, (b, (a, stack)))) = stack
-    expression = pushback(G if a > b else L if a < b else E, expression)
+    expression = concat(G if a > b else L if a < b else E, expression)
     return stack, expression, dictionary
 
 
@@ -13049,7 +13049,7 @@ E == pop swap roll< rest rest cons cons
 
-
In [14]:
+
In [31]:
from joy.library import FunctionWrapper, S_ifte
@@ -13102,7 +13102,7 @@ E == pop swap roll< rest rest cons cons
 
-
In [31]:
+
In [32]:
J("1 0 ['G'] ['E'] ['L'] cmp")
@@ -13133,7 +13133,7 @@ E == pop swap roll< rest rest cons cons
 
-
In [32]:
+
In [33]:
J("1 1 ['G'] ['E'] ['L'] cmp")
@@ -13164,7 +13164,7 @@ E == pop swap roll< rest rest cons cons
 
-
In [33]:
+
In [34]:
J("0 1 ['G'] ['E'] ['L'] cmp")
@@ -13195,7 +13195,7 @@ E == pop swap roll< rest rest cons cons
 
-
In [34]:
+
In [35]:
from joy.library import DefinitionWrapper
@@ -13220,7 +13220,7 @@ E == pop swap roll< rest rest cons cons
 
-
In [35]:
+
In [36]:
J('[] 23 "b" BTree-add')  # Initial
@@ -13251,7 +13251,7 @@ E == pop swap roll< rest rest cons cons
 
-
In [36]:
+
In [37]:
J('["b" 23 [] []] 88 "c" BTree-add')  # Less than
@@ -13282,7 +13282,7 @@ E == pop swap roll< rest rest cons cons
 
-
In [37]:
+
In [38]:
J('["b" 23 [] []] 88 "a" BTree-add')  # Greater than
@@ -13313,7 +13313,7 @@ E == pop swap roll< rest rest cons cons
 
-
In [38]:
+
In [39]:
J('["b" 23 [] []] 88 "b" BTree-add')  # Equal to
@@ -13344,7 +13344,7 @@ E == pop swap roll< rest rest cons cons
 
-
In [39]:
+
In [40]:
J('[] 23 "a" BTree-add 88 "b" BTree-add 44 "c" BTree-add')  # Series.
@@ -13503,7 +13503,7 @@ BTree-iter-order == [not] [pop] [dup third] [proc_left proc_current proc_right]
 
-
In [40]:
+
In [41]:
define('BTree-iter-order == [not] [pop] [dup third] [[cons dip] dupdip [[first] dupdip] dip [rest rest rest first] dip i] genrec')
@@ -13516,7 +13516,7 @@ BTree-iter-order == [not] [pop] [dup third] [proc_left proc_current proc_right]
 
-
In [41]:
+
In [42]:
J('[3 9 5 2 8 6 7 8 4] to_set BTree-iter-order')
@@ -13667,7 +13667,7 @@ BTree-get == [pop not] swap [] [P [T>] [E] [T<] cmp] genrec
-
In [42]:
+
In [43]:
# I don't want to deal with name conflicts with the above so I'm inlining everything here.
@@ -13694,7 +13694,7 @@ BTree-get == [pop not] swap [] [P [T>] [E] [T<] cmp] genrec
-
In [43]:
+
In [44]:
J('[] "gary" [popop "err"] BTree-get')
@@ -13725,7 +13725,7 @@ BTree-get == [pop not] swap [] [P [T>] [E] [T<] cmp] genrec
-
In [44]:
+
In [45]:
J('["gary" 23 [] []] "gary" [popop "err"] BTree-get')
@@ -13756,7 +13756,7 @@ BTree-get == [pop not] swap [] [P [T>] [E] [T<] cmp] genrec
-
In [45]:
+
In [46]:
J('''
@@ -14271,7 +14271,7 @@ BTree-Delete == [pop not] swap [R0] [R1] genrec
 
-
In [20]:
+
In [47]:
DefinitionWrapper.add_definitions('''
@@ -14298,7 +14298,7 @@ BTree-Delete == [pop not] swap [R0] [R1] genrec
 
-
In [23]:
+
In [48]:
J("['a' 23 [] ['b' 88 [] ['c' 44 [] []]]] 'c' ['Er'] BTree-Delete ")
@@ -14329,7 +14329,7 @@ BTree-Delete == [pop not] swap [R0] [R1] genrec
 
-
In [24]:
+
In [49]:
J("['a' 23 [] ['b' 88 [] ['c' 44 [] []]]] 'b' ['Er'] BTree-Delete ")
@@ -14360,7 +14360,7 @@ BTree-Delete == [pop not] swap [R0] [R1] genrec
 
-
In [25]:
+
In [50]:
J("['a' 23 [] ['b' 88 [] ['c' 44 [] []]]] 'a' ['Er'] BTree-Delete ")
@@ -14391,7 +14391,7 @@ BTree-Delete == [pop not] swap [R0] [R1] genrec
 
-
In [26]:
+
In [51]:
J("['a' 23 [] ['b' 88 [] ['c' 44 [] []]]] 'der' ['Er'] BTree-Delete ")
@@ -14422,7 +14422,7 @@ BTree-Delete == [pop not] swap [R0] [R1] genrec
 
-
In [30]:
+
In [52]:
J("['a' 23 [] ['b' 88 [] ['c' 44 [] []]]] 'der' [pop] BTree-Delete ")
@@ -14598,7 +14598,7 @@ treestep == swap [map] swoncat [TS1 [TS0] dip] dip genrec
-
In [46]:
+
In [53]:
DefinitionWrapper.add_definitions('''
@@ -14634,7 +14634,7 @@ treestep == swap [map] swoncat [TS1 [TS0] dip] dip genrec
-
In [47]:
+
In [54]:
J('[] 0 [sum +] [] treestep')
@@ -14665,7 +14665,7 @@ treestep == swap [map] swoncat [TS1 [TS0] dip] dip genrec
-
In [48]:
+
In [55]:
J('[23 []] 0 [sum +] [] treestep')
@@ -14696,7 +14696,7 @@ treestep == swap [map] swoncat [TS1 [TS0] dip] dip genrec
-
In [49]:
+
In [56]:
J('[23 [[2 []] [3 []]]] 0 [sum +] [] treestep')
@@ -14762,7 +14762,7 @@ K == [not] [pop z] [uncons [N] dip] [map C] genrec
-
In [50]:
+
In [57]:
define('TS1 == [dip] cons [uncons] swoncat')  # We only need to redefine one word.
@@ -14775,7 +14775,7 @@ K == [not] [pop z] [uncons [N] dip] [map C] genrec
-
In [51]:
+
In [58]:
J('[23 [2] [3]] 0 [sum +] [] treestep')
@@ -14806,7 +14806,7 @@ K == [not] [pop z] [uncons [N] dip] [map C] genrec
-
In [52]:
+
In [59]:
J('[23 [2 [8] [9]] [3] [4 []]] 0 [sum +] [] treestep')
@@ -14879,7 +14879,7 @@ key                     lkey rkey
-
In [53]:
+
In [60]:
J('[[3 0] [[2 0] [] []] [[9 0] [[5 0] [[4 0] [] []] [[8 0] [[6 0] [] [[7 0] [] []]] []]] []]]   23 [i] [uncons pop] treestep')
@@ -14932,7 +14932,7 @@ key               [ lk   rk  ]                 cons
 
-
In [57]:
+
In [61]:
J('[[3 0] [[2 0] [] []] [[9 0] [[5 0] [[4 0] [] []] [[8 0] [[6 0] [] [[7 0] [] []]] []]] []]]   [] [flatten cons] [first] treestep')
@@ -14985,7 +14985,7 @@ key  [lk] [rk] roll<
 
-
In [55]:
+
In [62]:
J('[[3 0] [[2 0] [] []] [[9 0] [[5 0] [[4 0] [] []] [[8 0] [[6 0] [] [[7 0] [] []]] []]] []]]   [] [i roll< swons concat] [uncons pop] treestep')
diff --git a/docs/Trees.md b/docs/Trees.md
index 90abf29..5a755f8 100644
--- a/docs/Trees.md
+++ b/docs/Trees.md
@@ -584,7 +584,7 @@ The definition is a little longer but, I think, more elegant and easier to under
 
 ```python
 from joy.library import FunctionWrapper
-from joy.utils.stack import pushback
+from joy.utils.stack import concat
 from notebook_preamble import D
 
 
@@ -607,7 +607,7 @@ def cmp_(stack, expression, dictionary):
                         L
     '''
     L, (E, (G, (b, (a, stack)))) = stack
-    expression = pushback(G if a > b else L if a < b else E, expression)
+    expression = concat(G if a > b else L if a < b else E, expression)
     return stack, expression, dictionary
 
 
diff --git a/docs/Trees.rst b/docs/Trees.rst
index edd773f..5cbe108 100644
--- a/docs/Trees.rst
+++ b/docs/Trees.rst
@@ -768,7 +768,7 @@ to understand:
 .. code:: ipython2
 
     from joy.library import FunctionWrapper
-    from joy.utils.stack import pushback
+    from joy.utils.stack import concat
     from notebook_preamble import D
     
     
@@ -791,7 +791,7 @@ to understand:
                             L
         '''
         L, (E, (G, (b, (a, stack)))) = stack
-        expression = pushback(G if a > b else L if a < b else E, expression)
+        expression = concat(G if a > b else L if a < b else E, expression)
         return stack, expression, dictionary
     
     
diff --git a/docs/sphinx_docs/_build/html/_modules/joy/library.html b/docs/sphinx_docs/_build/html/_modules/joy/library.html
index b9ac7d8..af5074a 100644
--- a/docs/sphinx_docs/_build/html/_modules/joy/library.html
+++ b/docs/sphinx_docs/_build/html/_modules/joy/library.html
@@ -245,42 +245,43 @@
 
 
 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
+disenstacken == ? [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
 '''
 #
 #
@@ -295,7 +296,6 @@
 ##second == rest first
 ##third == rest rest first
 ##swons == swap cons
-##swoncat == swap concat
 
 ##Zipper
 ##z-down == [] swap uncons swap
diff --git a/docs/sphinx_docs/_build/html/notebooks/Derivatives_of_Regular_Expressions.html b/docs/sphinx_docs/_build/html/notebooks/Derivatives_of_Regular_Expressions.html
index 4e249e6..f269260 100644
--- a/docs/sphinx_docs/_build/html/notebooks/Derivatives_of_Regular_Expressions.html
+++ b/docs/sphinx_docs/_build/html/notebooks/Derivatives_of_Regular_Expressions.html
@@ -499,7 +499,7 @@ machine transition table.

Says, “Three or more 1’s and not ending in 01 nor composed of all 1’s.”

-omg.svg

omg.svg

+omg.svg

omg.svg

Start at a and follow the transition arrows according to their labels. Accepting states have a double outline. (Graphic generated with diff --git a/docs/sphinx_docs/_build/html/notebooks/Intro.html b/docs/sphinx_docs/_build/html/notebooks/Intro.html index 61c82d1..129327f 100644 --- a/docs/sphinx_docs/_build/html/notebooks/Intro.html +++ b/docs/sphinx_docs/_build/html/notebooks/Intro.html @@ -197,7 +197,7 @@ provide control-flow and higher-order operations.

def dip(stack, expression, dictionary):
   (quote, (x, stack)) = stack
   expression = x, expression
-  return stack, pushback(quote, expression), dictionary
+  return stack, concat(quote, expression), dictionary
 

Some functions are defined in equations in terms of other functions. diff --git a/docs/sphinx_docs/_build/html/searchindex.js b/docs/sphinx_docs/_build/html/searchindex.js index 3de9c52..c33224e 100644 --- a/docs/sphinx_docs/_build/html/searchindex.js +++ b/docs/sphinx_docs/_build/html/searchindex.js @@ -1 +1 @@ -Search.setIndex({docnames:["index","joy","lib","library","notebooks/Categorical","notebooks/Derivatives_of_Regular_Expressions","notebooks/Developing","notebooks/Generator_Programs","notebooks/Intro","notebooks/Newton-Raphson","notebooks/NoUpdates","notebooks/Ordered_Binary_Trees","notebooks/Quadratic","notebooks/Recursion_Combinators","notebooks/Replacing","notebooks/The_Four_Operations","notebooks/Treestep","notebooks/TypeChecking","notebooks/Types","notebooks/Zipper","notebooks/index","parser","pretty","stack","types"],envversion:52,filenames:["index.rst","joy.rst","lib.rst","library.rst","notebooks/Categorical.rst","notebooks/Derivatives_of_Regular_Expressions.rst","notebooks/Developing.rst","notebooks/Generator_Programs.rst","notebooks/Intro.rst","notebooks/Newton-Raphson.rst","notebooks/NoUpdates.rst","notebooks/Ordered_Binary_Trees.rst","notebooks/Quadratic.rst","notebooks/Recursion_Combinators.rst","notebooks/Replacing.rst","notebooks/The_Four_Operations.rst","notebooks/Treestep.rst","notebooks/TypeChecking.rst","notebooks/Types.rst","notebooks/Zipper.rst","notebooks/index.rst","parser.rst","pretty.rst","stack.rst","types.rst"],objects:{"joy.joy":{joy:[1,1,1,""],repl:[1,1,1,""],run:[1,1,1,""]},"joy.library":{"void":[3,1,1,""],BinaryBuiltinWrapper:[3,1,1,""],DefinitionWrapper:[3,2,1,""],FunctionWrapper:[3,1,1,""],SimpleFunctionWrapper:[3,1,1,""],UnaryBuiltinWrapper:[3,1,1,""],add_aliases:[3,1,1,""],app1:[3,1,1,""],app2:[3,1,1,""],app3:[3,1,1,""],b:[3,1,1,""],branch:[3,1,1,""],choice:[3,1,1,""],clear:[3,1,1,""],cmp_:[3,1,1,""],concat_:[3,1,1,""],cond:[3,1,1,""],dip:[3,1,1,""],dipd:[3,1,1,""],dipdd:[3,1,1,""],divmod_:[3,1,1,""],drop:[3,1,1,""],dupdip:[3,1,1,""],floor:[3,1,1,""],genrec:[3,1,1,""],getitem:[3,1,1,""],help_:[3,1,1,""],i:[3,1,1,""],id_:[3,1,1,""],infer_:[3,1,1,""],infra:[3,1,1,""],initialize:[3,1,1,""],inscribe:[3,1,1,""],inscribe_:[3,1,1,""],loop:[3,1,1,""],map_:[3,1,1,""],max_:[3,1,1,""],min_:[3,1,1,""],parse:[3,1,1,""],pm:[3,1,1,""],pred:[3,1,1,""],remove:[3,1,1,""],reverse:[3,1,1,""],select:[3,1,1,""],sharing:[3,1,1,""],shunt:[3,1,1,""],sort_:[3,1,1,""],sqrt:[3,1,1,""],step:[3,1,1,""],succ:[3,1,1,""],sum_:[3,1,1,""],take:[3,1,1,""],times:[3,1,1,""],unique:[3,1,1,""],unstack:[3,1,1,""],warranty:[3,1,1,""],words:[3,1,1,""],x:[3,1,1,""],yin_functions:[3,1,1,""],zip_:[3,1,1,""]},"joy.library.DefinitionWrapper":{add_def:[3,3,1,""],add_definitions:[3,3,1,""],parse_definition:[3,3,1,""]},"joy.parser":{ParseError:[21,4,1,""],Symbol:[21,2,1,""],text_to_expression:[21,1,1,""]},"joy.utils":{generated_library:[3,0,0,"-"],pretty_print:[22,0,0,"-"],stack:[23,0,0,"-"],types:[24,0,0,"-"]},"joy.utils.generated_library":{ccons:[3,1,1,""],cons:[3,1,1,""],dup:[3,1,1,""],dupd:[3,1,1,""],dupdd:[3,1,1,""],first:[3,1,1,""],first_two:[3,1,1,""],fourth:[3,1,1,""],over:[3,1,1,""],pop:[3,1,1,""],popd:[3,1,1,""],popdd:[3,1,1,""],popop:[3,1,1,""],popopd:[3,1,1,""],popopdd:[3,1,1,""],rest:[3,1,1,""],rolldown:[3,1,1,""],rollup:[3,1,1,""],rrest:[3,1,1,""],second:[3,1,1,""],stack:[3,1,1,""],stuncons:[3,1,1,""],stununcons:[3,1,1,""],swaack:[3,1,1,""],swap:[3,1,1,""],swons:[3,1,1,""],third:[3,1,1,""],tuck:[3,1,1,""],uncons:[3,1,1,""],unit:[3,1,1,""],unswons:[3,1,1,""]},"joy.utils.pretty_print":{TracePrinter:[22,2,1,""]},"joy.utils.pretty_print.TracePrinter":{go:[22,5,1,""],viewer:[22,5,1,""]},"joy.utils.stack":{concat:[23,1,1,""],expression_to_string:[23,1,1,""],iter_stack:[23,1,1,""],list_to_stack:[23,1,1,""],pick:[23,1,1,""],stack_to_string:[23,1,1,""]},"joy.utils.types":{AnyJoyType:[24,2,1,""],BooleanJoyType:[24,2,1,""],CombinatorJoyType:[24,2,1,""],FloatJoyType:[24,2,1,""],FunctionJoyType:[24,2,1,""],IntJoyType:[24,2,1,""],JoyTypeError:[24,4,1,""],KleeneStar:[24,2,1,""],NumberJoyType:[24,2,1,""],StackJoyType:[24,2,1,""],SymbolJoyType:[24,2,1,""],TextJoyType:[24,2,1,""],compilable:[24,1,1,""],compile_:[24,1,1,""],compose:[24,1,1,""],delabel:[24,1,1,""],doc_from_stack_effect:[24,1,1,""],infer:[24,1,1,""],meta_compose:[24,1,1,""],poly_compose:[24,1,1,""],reify:[24,1,1,""],relabel:[24,1,1,""],type_check:[24,1,1,""],uni_unify:[24,1,1,""]},"joy.utils.types.BooleanJoyType":{accept:[24,6,1,""]},"joy.utils.types.FloatJoyType":{accept:[24,6,1,""]},"joy.utils.types.IntJoyType":{accept:[24,6,1,""]},"joy.utils.types.KleeneStar":{kind:[24,6,1,""]},"joy.utils.types.StackJoyType":{accept:[24,6,1,""]},"joy.utils.types.TextJoyType":{accept:[24,6,1,""]},joy:{joy:[1,0,0,"-"],library:[3,0,0,"-"],parser:[21,0,0,"-"]}},objnames:{"0":["py","module","Python module"],"1":["py","function","Python function"],"2":["py","class","Python class"],"3":["py","classmethod","Python class method"],"4":["py","exception","Python exception"],"5":["py","method","Python method"],"6":["py","attribute","Python attribute"]},objtypes:{"0":"py:module","1":"py:function","2":"py:class","3":"py:classmethod","4":"py:exception","5":"py:method","6":"py:attribute"},terms:{"05s":5,"0b11100111011011":6,"23rd":18,"5bkei":11,"\u03b4":5,"\u03b5":9,"abstract":[8,11],"boolean":[2,3,8,11,15],"break":[5,8,18],"byte":[5,6],"case":[2,3,13,15,16,18,23],"char":5,"class":[3,5,8,18,21,22,23,24],"default":[3,7,11,23],"export":[3,21],"final":[2,11,13],"float":[3,8,18,19,21,24],"function":[0,1,4,6,7,10,12,17,19,20,21,22,23,24],"g\u00e9rard":19,"goto":5,"import":[2,5,6,7,9,11,12,13,14,16,17,18,19],"int":[5,7,8,13,18,19,21,23,24],"long":[11,18,20],"new":[2,3,5,7,8,10,13,14,18,24],"p\u00f6ial":20,"p\u00f6ial06typingtool":18,"public":10,"return":[1,3,5,6,8,11,13,14,15,16,18,21,22,23,24],"static":[2,10],"super":18,"switch":[2,18],"throw":[11,24],"true":[2,3,5,6,13,15,18,24],"try":[7,9,12,13,16,17,18,20],"void":[0,3],"while":[3,5,8,11,18,21,23],AND:[5,18],Adding:[8,14,20],And:[5,6,7,9,11,13,15,18,19,23],But:[0,4,6,7,8,11,14,18],CPS:8,For:[2,3,11,13,14,18,20,23,24],Its:3,NOT:5,Not:18,One:[2,8,15,18,20],REs:5,TOS:[2,3],That:[6,11],The:[0,1,2,3,4,5,7,9,10,12,19,20,21,23,24],Then:[2,3,11,12,13,18],There:[5,12,13,15,16,18,23],These:[15,18,20,23,24],Use:[3,9,13],Used:15,Using:[0,9,11,20],With:[9,13,18,20,24],_1000:18,__add__:18,__builtin__:24,__call__:5,__class__:18,__eq__:18,__ge__:18,__hash__:18,__init__:[5,18],__main__:18,__radd__:18,__repr__:18,__str__:22,_and:5,_compaction_rul:5,_con:5,_dictionari:18,_ge:18,_infer:18,_interpret:18,_log:18,_log_it:18,_names_for:18,_or:5,_templat:5,_to_str:18,_tree_add_:11,_tree_add_e:[11,24],_tree_add_p:11,_tree_add_r:11,_tree_add_t:11,_tree_delete_:11,_tree_delete_clear_stuff:[11,24],_tree_delete_del:11,_tree_delete_r0:[11,24],_tree_delete_r1:11,_tree_delete_rightmost:11,_tree_delete_w:11,_tree_get_:[11,24],_tree_get_p:11,_tree_get_r:11,_tree_get_t:11,_tree_iter_order_curr:11,_tree_iter_order_left:11,_tree_iter_order_r:11,_tree_iter_order_right:11,_tree_t:11,_treestep_0:16,_treestep_1:16,_uniqu:18,_within_b:9,_within_p:9,_within_r:9,a10001:18,a10002:18,a10003:18,a10004:18,abbrevi:16,abl:[5,15,18,24],about:[0,8,11,15,18,19,23],abov:[0,5,6,9,11,13,15,18],abs:9,absolut:8,accept:[1,2,3,5,6,7,8,11,12,14,15,16,18,19,24],accord:5,accordingli:[11,15],accumul:6,act:[5,24],action:[0,8,14,18,19,20],actual:[2,6,8,11,15,18],adapt:20,add:[3,5,6,7,8,14,18,22,24],add_alias:3,add_def:3,add_definit:[3,11,16],added:[4,11],adding:[10,18],addit:[0,2,3,6,8,13,14,16],address:20,adjust:11,advantag:18,affect:[3,15],after:[5,6,7,8,13,15,18,24],afterward:8,again:[2,3,6,8,11,13,18,24],against:[18,24],aggreg:19,ahead:18,aka:[5,8,19,24],albrecht:0,algorithm:[5,8,18],alia:[3,24],alias:[3,8],align:[8,22],all:[3,5,6,7,8,11,13,14,15,16,18,22,24],alloc:18,allow:[10,11,15],almost:11,along:[5,8,13,18,24],alphabet:[3,20],alreadi:[5,9,14,18,19],also:[0,5,6,8,11,15,18,23,24],alter:[5,18],altern:[4,18,24],although:[4,11],altogeth:7,alwai:[6,10,13,15],amend:15,among:18,amort:11,analysi:[4,20],anamorph:[8,20],ani:[4,5,6,8,10,11,15,18,19,21,24],annual:8,anonym:11,anoth:[5,11,15,18,23,24],anyhow:[15,18],anyjoytyp:[18,24],anymor:18,anystarjoytyp:18,anyth:[2,3,5,8,18,24],apart:18,api:10,app1:3,app2:[3,8,12,13,14,15],app3:[3,15],app:8,appear:[2,4,5,6,11,24],append:18,appendix:20,appli:[2,3,6,7,11,13,18,24],applic:7,approach:6,appropri:5,approxim:20,archiv:0,aren:19,arg:[2,3],argument:[2,3,8,9,12,13,20,22,23],arithmet:2,ariti:[2,15],around:[6,18,21,23],arrang:16,arriv:[7,16],arrow:5,articl:[0,4,7,13],ascii:5,ascii_lowercas:5,ask:[4,7,18],aspect:0,assembl:5,assert:[5,18],assign:[15,23],associ:11,assum:9,asterisk:16,asterix:[18,24],asyncron:15,attack:8,attempt:[0,1,3,18],attribut:3,attributeerror:18,author:18,auto:[0,18,24],automat:[4,15,18,24],auxiliari:[5,16],avail:[0,18,24],averag:[8,14],avoid:[11,24],awai:[11,18],awar:2,awkward:[11,13,18],azur:20,back:[11,18],backtrack:24,backward:[10,11,12,16],bad:18,bag:8,banana:13,bar:15,barb:13,base:[0,2,3,10,13,16,18],basestr:24,basic:[2,3,8,11],basicconfig:[17,18],becaas:5,becaus:[2,3,5,8,11,15,16,18,19,23,24],becom:[11,16,23],becuas:18,been:[5,9,10,11,18,19],befor:[5,7,8,11],begin:[11,16],behavior:[10,16,24],behaviour:[0,1,18,24],behind:15,being:[0,15,24],below:[2,3,5,6,7,11,18,19],bespok:8,best:0,better:[6,11,13,18],between:[0,6,24],beyond:7,biannual:8,bin:5,binari:[0,7,8,20],binary_search_tre:11,binarybuiltinwrapp:3,bind:8,bingo:19,bit:[5,6,7,11,18],blank:21,bliss:[0,20],block:6,bodi:[2,3,5,8,11,15],body_text:3,booktitl:18,bool:[13,18,24],booleanjoytyp:24,borrow:[8,18],both:[2,6,8,12,13,14,15,18,23],bottom:7,bounce_to:5,bracket:[8,18,21],branch:[3,5,6,7,13,18,20,24],branch_fals:18,branch_tru:18,breakpoint:8,bring:[6,8,18],bruijn:18,brutal:15,brzozowski:[18,20],brzozowskian:5,btree:[11,16],buck:11,bug:[0,8],build:[7,8,12,13,19,23],built:[12,18],bundl:[2,3,13],burgeon:8,calculu:4,call:[1,2,5,8,10,11,13,15,18,22,23],caller:[11,18],can:[0,2,3,4,5,6,7,8,9,10,12,13,14,15,16,18,19,20,21,23,24],cancel:15,cannot:[17,18,21],captur:8,card:8,care:[6,23],carefulli:19,carri:[7,11,24],cartesian:4,catamorph:20,categor:[0,20],categori:[4,15],ccc:4,ccon:[3,11,17,18,24],cell:[13,18],certain:[8,23],certainli:11,chain:[3,15],chang:[2,10,11,18,19],charact:[5,19],chat:8,chatter:[0,18],check:[0,7,9,18,20,24],child:16,choic:[3,13],choos:10,chop:12,chose:5,cinf:11,circl:5,circuit:4,cite_not:11,classmethod:3,claus:[3,18],clean:18,clear:[3,6,8],clear_stuff:11,cleav:[8,12,14],close:[0,1,4],clunki:[6,18],clv:15,cmp:[3,16,20],cmp_:3,code:[0,1,4,5,12,13,15,18,20,24],codireco:[7,9],collaps:13,collect:[4,5,7,8,18],collis:24,combin:[0,3,6,7,8,9,12,15,16,19,20,24],combinatorjoytyp:[18,24],come:[8,11,18],command:[8,11,18],comment:[15,24],common:[2,6,15],compar:[3,4,5,18],comparison:[0,11],compat:15,compel:4,compil:[2,3,4,5,8,11,14,15,20,24],compile_:24,complement:5,complet:[3,4],complex:[3,15,18,19,24],complic:18,compos:[5,24],composit:[18,24],compostit:18,compound:11,comput:[2,4,5,6,8,12,15,18,24],con:[3,5,6,7,8,9,11,12,13,15,16,19,23,24],conal:[4,15],concat:[3,7,8,15,16,18,23],concat_:3,concaten:[0,5],concatin:[0,3,5,23],concern:15,conclus:20,concurr:2,cond:[3,11],condit:[3,8],confer:18,conflict:[11,18,24],consecut:20,consid:[5,6,7,11,13,16,18,19],consist:[2,7,8,15,16],constant:11,constitu:13,construct:[15,18],consum:[15,18],contain:[0,2,3,5,7,8,13,18,21],content:18,context:2,conting:11,continu:[0,5,13,18,19],control:8,conveni:[4,15,18],convent:15,convers:18,convert:[13,14,16,18,21,23],cool:11,copi:[2,3,6,11,13,15,16,17,20],copyright:8,correspond:[4,15],could:[2,4,5,6,8,10,11,15,18,19],couldn:15,count:[3,18],counter:[6,18],coupl:16,cours:[6,11,18],cover:18,cpu:15,crack:11,crash:11,creat:[0,2,3,6,9,11,15,18],creativ:18,crude:[11,18,21,24],cruft:18,curent:24,current:[2,3,8,13,15,16,18,19,22,24],curri:5,custom:10,cycl:[6,7],cython:8,d010101:5,d0101:5,d01:5,d10:5,d_compact:5,dai:8,data:[2,3,5,13],datastructur:[0,2,13,18,20,21,23],datatyp:23,ddididi:19,deal:[0,5,11,15],dealt:18,debugg:18,decid:11,declar:18,decor:3,decoupl:13,decrement:3,deduc:[6,18],deeper:0,deepli:4,def:[3,5,8,13,14,18,23],defaultdict:[5,18],defi:3,defin:[2,3,4,5,6,7,8,9,10,12,13,14,15,18,19,20],definit:[0,2,3,6,7,8,10,11,13,16,18,20,24],definitionwrapp:[3,11,13,16],defint:15,del:17,delabel:24,deleg:8,delet:20,deliber:18,demo:18,demonstr:4,depend:[3,11,13,15],deposit:16,depth:[18,24],dequot:13,der:11,deriv:[2,3,6,8,9,11,18,20],derv:5,describ:[3,4,5,11,13,15,16,18,21,24],descript:[6,8],descriptor:18,design:[2,3,11,15,20],desir:[8,16],destin:5,destruct:11,detail:[8,11,18],detect:[5,7,11,13,18],determin:20,develop:[0,7,8,18,20],diagram:6,dialect:1,dict:[1,3,5,18,24],dictionari:[0,1,3,8,18,20],did:18,differ:[0,4,6,9,11,12,13,15,23],differenti:4,difficult:18,difficulti:15,dig:[11,19],digit:6,digraph:5,dinfrirst:[8,18,24],dip:[3,6,7,8,9,11,12,13,14,15,16,18,20,24],dipd:[3,7,8,11,12,13,15,18,19,24],dipdd:[3,11],direco:20,direct:8,directli:[6,15,16,18,23],disappear:[2,5,18,24],discard:[3,7,9,11,13],disciplin:11,disctionari:1,disenstacken:8,disk:8,displac:2,displai:18,distiguish:18,distribut:15,ditch:11,div:[3,8,18,24],dive:16,divis:11,divmod:[3,24],divmod_:[3,18],doc:[2,3,8,18,24],doc_from_stack_effect:[17,24],docstr:18,document:[18,20,21,23],doe:[0,1,3,4,5,7,8,14,15,18,20,22,24],doesn:[6,10,11,15,16,18,23],doing:[4,6,8,15,18,19],domain:[4,18],don:[5,6,8,11,18,24],done:[2,6,8,10,18],dooooc:18,door:8,dot:[5,22],doubl:[3,5,6,8,18],doublecircl:5,down:[2,5,9,13,19,24],down_to_zero:8,dozen:8,draft:[4,10],dream:8,drive:[7,9],driven:6,driver:[5,7],drop:[3,11],dudipd:8,due:18,dup:[3,6,7,8,9,11,12,13,15,17,19,23,24],dupd:[3,18,24],dupdd:[3,24],dupdip:[3,6,11,12,13],duplic:[3,11,13],durat:2,dure:[2,13],each:[2,3,4,5,6,8,13,14,15,16,18,22,24],easi:[0,11,16,18,19],easier:[3,11,15],easili:4,eat:5,edit:20,effect:[2,3,5,8,15,19,20,24],effici:[7,14,19],efg:18,either:[1,2,3,5,11,13,18],elabor:18,eleg:[0,5,8,11,15,20],element:2,elif:18,elimin:[5,18],elliott:[4,15],els:[2,3,5,13,15,18],else_:18,embed:[4,11,19],emit:18,empti:[3,5,8,16,18,23,24],encapsul:8,enclos:8,encod:7,encount:18,end:[5,6,11,13,16,18,23],endless:7,enforc:[2,8],engend:8,enough:[5,8,13,22,24],enstacken:[7,8,18],enter:[3,8,24],enter_guard:18,entir:23,entri:[3,19,22],enumer:18,epsilon:9,equal:[3,6,16,23],equat:[8,9],equival:15,ergo:[5,11],err:[11,17],error:[8,18,21],essai:0,establish:18,etc:[3,16,18,19,21],euler:20,euro:18,eval:[0,18],evalu:[1,2,3,8,9,11,12,13,14,15,16,18],event:15,eventu:[15,18],ever:18,everi:[1,7,15],everybodi:15,everyth:[3,5,11,12,15,18],evolv:10,examin:13,exampl:[0,3,5,6,18,20,21,23,24],exce:7,except:[5,8,11,17,18,21,24],execut:[0,1,2,3,8,13,14,15,16,18,19,23,24],exend:18,exercis:[5,11],exist:[4,11,18],expand:11,expect:[2,3,15,16,18,23,24],experi:[8,16],explain:18,explan:8,explor:[8,18],express:[0,1,2,3,4,11,13,14,18,19,20,22,23],expression_to_str:[18,23],extend:18,extra:[6,7],extract:[11,12,20],extrem:8,extrememli:8,f_g:18,f_in:18,f_out:18,f_python:18,facet:0,facil:8,fact:21,factor:[2,6,8,11,18],factori:20,fail:[2,3,11,20,21,24],fail_fail:3,fairli:18,fake:5,fall:18,fals:[2,3,5,6,13,15,18,24],falsei:18,far:[9,11,13,18,24],fascin:0,favorit:15,fear:[11,18],few:[6,8,9,12,15,18],fewer:[3,8],fg_in:18,fg_out:18,fib:7,fib_gen:7,fibonacci:20,figur:[2,3,11,13,18],filter:11,fin:6,find:[2,3,5,6,7,15,16,18,20],finder:9,fine:[0,5,6,11,18,24],finite_state_machin:5,first:[3,5,7,8,9,11,12,13,14,16,19,20,24],first_two:[3,11,24],fit:[6,8],five:[6,8,20],fix:[2,3,5,13,18,24],fixm:[5,18],flag:[15,18],flatten:[8,16,18],flesh:5,flexibl:20,floatjoytyp:[18,24],floatstarjoytyp:18,floor:3,floordiv:[6,24],flow:8,follow:[0,2,3,5,8,10,13,15,16,18,19,24],foo:[8,10,11,15,18],foo_ii:10,fork:15,form:[2,3,4,5,6,7,13,16,18,23],forman:8,format:[17,18,20,22],formula:[0,6,20],forth:[8,18],forum:0,forward:18,found:8,four:[0,2,3,6,7,8,11,20],fourteen:6,fourth:[2,3,11,13,24],fractal:8,fraction0:8,fraction:[2,8],frame:13,framework:8,free:[4,8,11],freeli:2,from:[0,1,2,3,5,6,7,8,9,11,12,13,14,15,16,17,18,19,20,23],from_:5,front:[2,3,13],frozenset:5,fulin:15,full:6,fun:[5,20],func:18,functionjoytyp:[18,24],functionwrapp:3,functool:5,fundament:[0,20],funtion:11,further:[9,18,20],futur:15,g_in:18,g_out:18,garbag:8,gari:11,gcd:8,gener:[0,2,4,13,15,18,20,23,24],generated_librari:3,genrec:[3,8,11,13,15,16,18],geometr:6,get:[2,4,5,6,7,8,12,13,18,20],getch:5,getitem:3,getrecursionlimit:23,getsourc:8,ghc:4,give:[4,6,11,13,16,18,23],given:[2,3,6,7,9,11,13,15,18,19,20],global:[17,18],glue:8,goe:24,going:[5,11,12,15,16,18,19],good:[6,11,18],grab:18,grammar:21,grand:8,graph:15,graphic:5,graphviz:5,great:[0,8,18,20],greater:23,grind:18,group:0,grow:5,gsra:9,guard:[11,18,24],had:[5,6,19],haiku:8,half:[6,18,19],hallmark:15,hand:[5,8,14,18,20],handi:[9,18],handl:[11,18,23,24],happen:[8,18],happi:5,hard:[5,18,19],hardwar:4,has:[0,2,5,7,8,9,10,11,13,15,18,19,23],hasattr:18,hash:18,haskel:4,have:[2,3,5,6,7,8,9,10,13,14,15,18,19,20,23,24],haven:24,head:23,heh:18,help:[8,11,13,18],help_:3,helper:[3,5],herd:8,here:[5,6,7,11,16,18,19,24],hide:11,hierarchi:18,higher:[5,8,11,18],highli:8,hij:5,histori:[18,22,24],hit:5,hmm:[5,11],hoist:3,hold:[6,18],hood:11,hope:[0,6,8,20],hopefulli:13,host:20,how:[0,4,5,9,11,13,18,19,20],howev:[13,14,15,18],html:[2,3,7,12,13,20],http:11,huet:19,huge:11,hugh:[9,16],human:8,hybrid:24,hylomorph:20,hypothet:2,id_:3,idea:[4,6,8,18],ident:[3,5,13,18,24],if_not_empti:11,ift:[3,11,13,16,18,24],ignor:[1,3,11,18],iii:20,illustr:[5,13],imagin:[5,15,19],imap:18,imit:[5,16],immedi:[5,13],immut:[5,8,11],imper:13,implement:[0,1,2,3,4,8,10,11,13,14,15,20,24],implementaion:15,implicit:8,improv:18,includ:[4,11,15,16,18,24],inclus:6,incom:23,incompat:10,incorpor:12,increas:6,increment:[3,4,6,10,15],indetermin:24,index:[0,8,18,23],indexerror:23,indic:[15,16,18,24],ineffici:18,infer:[0,3,17],infer_:3,inferenc:24,info:[17,18],inform:[3,5,18,24],infra:[3,7,8,11,12,14,15,16,18,20,24],infrastructur:3,initi:[2,3,5,8,9,11,18],inlin:11,inner:18,inproceed:18,input:[1,9,15,17,18,24],input_:5,inscrib:3,inscribe_:3,insert:18,insight:13,inspect:8,inspect_stack:18,instal:0,instanc:18,instanti:[4,22],instead:[5,6,7,11,13,18,19,23,24],instruct:5,integ:[2,3,8,13,16,18,21],integr:3,intend:[0,8],interact:[8,20],interest:[0,6,11,18,20],interfer:15,interlud:20,intermedi:13,intern:[0,18,22,23],interpret:[0,4,10,14,21,22,24],interrupt:8,intersect:5,interspers:15,interv:[4,6],intjoytyp:[18,24],introduc:10,introduct:0,intstarjoytyp:18,intuit:18,invalid:24,invari:3,invent:18,involv:18,ipf:8,isinst:[5,18],isn:[5,11,19],issubclass:18,item:[2,3,8,11,13,15,16,18,20,23],iter:[1,3,5,8,13,15,16,18,20,23],iter_stack:[14,23],iteritem:[5,18],itertool:[5,18],its:[0,1,2,3,4,6,8,11,13,15,16,18,23],itself:[0,2,8,11,15,18,24],j05cmp:[2,3,13],jaanu:18,jmp:5,job:[15,20],john:[9,16],joi:[2,4,10,11,12,14,15,17],join:[5,18],joypi:[8,19],joytypeerror:[17,24],jump:5,jump_from:5,junk:18,jupyt:20,just:[0,2,3,5,7,8,10,11,13,15,16,18,19],juxtaposit:15,keep:[5,11,12,15,18,19],kei:[5,16,20],kevin:0,key_n:11,keyerror:[5,11,18],kind:[2,4,8,11,13,16,18,24],kinda:18,kleen:[16,18,24],kleenestar:[18,24],kleffner:18,know:[6,11,18],knowledg:18,known:[4,15],kstar:5,l_kei:11,l_left:11,l_right:11,l_valu:11,label:[5,18],lambda:[4,5,18],languag:[4,5,8,10,11,14,18],larg:[5,18],larger:[20,23],largest:3,last:[6,11,13,18],lastli:7,later:[5,8,16,18],law:2,lazi:18,lazili:9,lcm:6,lead:[5,8,18,24],leaf:11,lean:8,learn:0,least:[2,6,13,18,23],least_fract:8,leav:[6,15],left:[5,8,12,13,15,16,18,19,22,23,24],leftov:13,legend:5,len:[5,18],length:[3,6,23],lens:13,less:[6,7,8,13,18,23],let:[7,9,11,12,13,16,18,19,20],letter:18,level:[4,5,11,17,18],librari:[0,5,14],like:[2,3,5,6,8,15,16,18,20,21,24],limit:[18,24],line:[3,8,11,12,18,22,24],linear:23,link:[0,5,18],linux:0,list:[0,3,5,6,8,9,11,13,15,16,18,19,22,24],list_to_stack:[18,23],liter:[1,11,16,18,19,21],literatur:18,littl:[5,7,11,15,18,20],live:20,lkei:16,load:[6,8],local:18,locat:2,locu:22,log:[17,18],log_2:11,logic:[0,6,20],longer:[11,18],look:[1,5,7,8,9,11,12,15,18],lookup:8,loop:[0,1,3,5,6,18,20,24],lose:18,lot:[5,8,11,18,19],love:6,low:[4,5],lower:6,lowercas:[5,18],lowest:11,lshift:24,machin:[0,20],machineri:[11,18],macro:8,made:[0,8,15,18,19],magic:18,mai:[2,13,15],mail:0,main:[0,3,8,12,15,18,19],mainloop:10,maintain:19,major:10,make:[2,3,4,6,8,11,13,14,15,16,18,19,20],make_gener:9,make_graph:5,manfr:[0,2,3,4,13],mani:[0,5,8,18],manipul:18,manner:12,map:[1,3,5,6,8,10,13,16,18],map_:3,marker:8,mask:[6,7],match:[0,1,18,20],materi:0,math:[0,8,9,11,12,18],mathemat:8,matter:[6,9,11,16],max_:3,maximum:3,mayb:[11,18],mean:[3,4,6,8,9,11,13,16,18,23,24],meant:[8,11,13,16],mem:5,member:[2,3,13],memo:5,mental:8,mention:2,mercuri:0,mess:18,messag:[17,18],meta:[8,11,14],meta_compos:[18,24],method:[0,3,8,18,20,22],midpoint:6,might:[4,5,7,11,18],mike:11,million:7,min_:3,mind:18,minimum:3,minor:11,minu:3,mirror:0,miscellan:0,mismatch:18,mix:[8,18],mod:3,mode:18,model:[4,8],modern:0,modif:[7,18],modifi:[8,11,19],modul:[0,1,3,8,18,21],modulu:[8,24],moment:18,month:8,more:[0,3,4,5,6,7,8,9,13,14,15,16,18,21,23,24],most:[5,18,24],mostli:0,move:[5,11],movement:2,much:[5,6,7,11,13,18],muck:11,mul:[3,8,12,17,19,22,24],multi:3,multipl:[20,24],must:[2,3,6,10,13,15,16,18,21],myself:18,n10001:18,n10002:18,n10003:18,n1001:18,n1002:18,n1003:18,name:[1,3,5,8,10,11,13,18,19,20,21,23,24],narr:18,natur:[5,6,7,11,18],navig:19,nearli:18,neat:11,neato:18,necessarili:18,need:[2,3,6,7,9,10,11,13,15,18],neg:[3,12,24],neither:[15,18],ness:5,nest:[3,8,11,19],network:8,never:[5,10,13],new_def:18,new_f:18,new_fo:18,new_kei:11,new_valu:11,newton:[0,20],next:[5,6,15,16,18,24],nice:[0,5,13,23],niether:2,node:[5,16,20],node_kei:11,node_valu:11,non:[5,16,18,24],none:[1,3,18,24],nope:16,nor:5,normal:15,notat:[8,11],note:[2,5,6,9,11,13,15,18,23],notebook:[6,7,8,18,19,20],notebook_preambl:[2,6,7,9,11,12,13,14,16,18,19],noth:[2,11,15],notic:6,now:[5,6,7,8,13,14,16,18,20],nth:[3,23],nullari:[8,11,15,18,24],number:[1,2,3,6,7,9,15,23,24],numberjoytyp:[18,24],numberstarjoytyp:18,numer:18,object:[5,18,21],observ:6,obviou:7,obvious:18,occur:11,odd:[6,7],off:[2,3,6,7,12,18,19],often:[5,15],old:[2,14],old_k:11,old_kei:11,old_valu:11,omg:5,omit:[13,18,21],onc:[3,5,10,11],one:[2,3,5,6,7,11,13,15,16,18,22,23,24],ones:[5,7,18],onli:[2,3,5,6,11,13,15,18,19,23,24],onto:[1,2,3,8,13,23],open:[8,18],oper:[0,3,5,8,11,13,20,23],oppos:18,optim:11,option:[1,8,11,18,23],orchestr:15,order:[0,2,3,8,13,15,17,18,20,23],org:[0,11],origin:[0,1,2,3,11,19],other:[0,2,3,4,5,8,11,13,16,18,23,24],otherwis:[3,5,6,7,11,16,18,24],our:[5,6,7,8,9,13,16,18],out:[2,3,4,6,7,8,9,11,12,13,15,18,19,20],outcom:16,outlin:5,output:[5,9,13,15,17,18,24],outsid:4,over:[3,4,6,7,8,9,11,12,15,16,18,20,24],overhaul:18,overview:18,own:[11,18],pack:23,packag:[0,8],page:[0,11,18,23],pair:[2,3,6,7,11,18],palidrom:6,palindrom:6,pam:8,paper:[4,8,13,15,19],paradigm:20,parallel:[2,20],paramet:[1,2,3,13,14,21,22,23],parameter:20,paramorph:13,parenthes:[11,23],pariti:7,pars:[0,3,5,8],parse_definit:3,parseerror:21,parser:[0,17,18],part:[2,3,9,13,16,20],partial:[5,18],particular:19,pass:[0,5,11,18,22,24],patch:5,path:[5,18,20],pattern:[5,6,15,16,20],pe1:[6,7],pe2:7,pearl:19,pend:[3,8,13,18,19,22],peopl:20,per:[8,16],perfectli:15,perform:[5,15,18],perhap:7,period:8,permit:[15,18,23],permut:18,persist:[3,11],phase:2,phi:5,pick:[6,7,15,23],pickl:8,pictur:11,piec:13,pip:0,place:[3,6,8,18],plai:0,plu:3,plug:[7,13,16],point:[4,5,8,11,13,15],pointless:2,poly_compos:24,polytyp:[0,17,18],pool:15,pop:[3,5,6,7,8,11,13,14,16,17,23,24],popd:[3,8,9,11,14,15,18,24],popdd:[3,7,12,18,24],popop:[3,6,7,8,9,11,16,18,24],popopd:[3,24],popopdd:[3,24],posit:[3,6,8,13],possibilit:11,possibl:[11,16,18,20],post:8,poswrd:18,potenti:15,pow:24,power:[8,18],pprint:5,pragmat:6,preambl:9,preceed:15,precis:[0,1],pred:[3,18,24],predic:[2,3,5,7,13,15,24],prefix:[18,22],preliminari:5,present:18,preserv:[4,16],pretti:[9,11,12,15,16,18,22,23],pretty_print:0,previou:[8,15],prime:9,primit:[2,3,18,20],primrec:[3,7,8,9,13],print:[0,1,2,3,5,17,18,22,23,24],probabl:[7,8,11,18],problem:[8,18,20],proc_curr:11,proc_left:11,proc_right:11,proce:[6,24],process:[5,8,16,18,22],produc:[6,11,13,16,18],product:[5,7,8,17,18],program:[0,2,3,7,8,9,11,13,15,18,19,24],programm:[15,18],progress:15,project:20,prolog:18,promis:15,prompt:8,proper:[2,3,13,15,24],properti:0,provid:[0,3,4,8,15,18,24],pun:[0,8],punctuat:18,pure:[0,5],puriti:8,purpos:8,push:[2,3,8,13,19,23],pushback:8,put:[1,2,7,8,15,18,20,23],pypi:0,python:[0,2,3,5,11,13,15,19,20,21,23,24],quadrat:[0,20],queri:[11,16],query_kei:16,queu:13,quit:[0,16],quot:[0,3,7,8,11,12,13,15,16,18,19,22,24],quotat:[2,3,13],quotient:3,r_kei:11,r_left:11,r_right:11,r_valu:11,rais:[5,11,18,21,23],rang:[5,8,18],range_revers:13,range_to_zero:8,ranger:13,ranger_revers:13,rankdir:5,raphson:9,rather:[6,8,13,16],ratio:8,reach:[5,6,7,13],read:[0,1,6,7,11,18,19],readabl:14,reader:[5,11],readi:18,real:11,realiz:[4,11],rearrang:[2,3,11,18],reason:[6,8,15,18],rebuild:[16,19],rec1:[2,3,13],rec2:[2,3,13],recogn:21,recombin:15,record:[8,22],recur:[13,18],recurs:[0,2,3,5,7,8,9,15,18,20,23],recus:8,redefin:20,redistribut:[3,8],redo:5,reduc:[2,18],redund:23,refactor:[8,10],refer:[0,2],referenti:15,reflect:15,regard:15,regist:2,regular:[18,20,21],reifi:[17,24],reimplement:[15,20],relabel:24,relat:[5,18],releas:10,remain:[2,8,10,18],remaind:[3,9],rememb:5,remind:18,remov:[3,11,18,23],render:20,repeat:6,repeatedli:6,repetit:5,repl:[0,1],replac:[0,2,3,7,12,13,15,16,18,19,20,23],repositori:0,repr:[5,18],repres:[2,8,11,15,21,22,24],represent:[23,24],reprod:7,repurpos:18,requir:[15,18,23],res:18,research:18,resembl:8,resolut:15,resourc:[3,15],respect:[5,6,15],rest:[3,6,7,8,11,13,19,20,23,24],rest_two:11,restart:3,restor:2,result:[1,2,3,5,6,11,12,13,15,16,18,19],resum:8,retir:2,retri:8,reus:[11,18],revers:[3,6,7,13,18,19,20,23],revisit:18,rewrit:[3,8,18],rewritten:8,rid:11,right:[7,8,12,16,18,20,22,23,24],rightest:11,rightmost:6,rigor:15,risk:18,rkei:16,rob:18,roll:[3,9,11,16],roll_dn:18,rolldown:[3,17,18,24],rollup:[3,18,24],root:[3,9,12],round:18,row:5,rrest:[3,17,18,24],rshift:24,rule:[15,20],run:[0,1,3,6,8,9,11,12,13,15,16,18,19],runtim:15,runtimeerror:23,sai:[5,7,11,12,16,18],same:[2,4,6,11,15,18,23],sandwich:[2,3,13],save:[2,5,6,8],scan:3,scanner:[8,21],scenario:19,scope:[7,11],search:[0,11],sec:[18,24],second:[3,8,11,13,16,23,24],section:13,see:[0,5,7,8,9,10,12,13,14,18,19,22],seem:[0,6,8,16,18,24],seen:[18,19,24],select:3,self:[5,15,18],semant:[2,3,8,10,11,15,18],semi:8,send:8,sens:[0,2,6,18,19],separ:[8,15,18,21],seq:18,sequenc:[0,1,2,3,6,8,11,13,14,19,20,21,24],sequence_to_stack:18,seri:[6,7,11,19],ses:18,set:[2,3,5,13,18,20],seven:[6,7],sever:[0,4,8,13],shape:[5,15],share:[3,8],shelf:2,shew:5,shift:[6,7],shorter:20,shorthand:11,should:[2,3,5,6,11,13,15,18],shouldn:8,show:[4,15,18,19],shunt:[3,19],side:[5,11,17,18,24],sign:3,signatur:24,signifi:[8,11],similar:[11,16,18],simon:8,simpl:[5,8,13,23,24],simplefunctionwrapp:[3,14,18],simpler:16,simplest:[18,20],simpli:4,simplifi:[6,11,19],sinc:[2,6,11,18],singl:[3,7,8,14,15,18,21,24],singleton:5,situ:11,situat:11,six:[6,7,8],sixti:[6,7],size:[5,8,20],skeptic:8,skip:18,slight:9,slightli:[11,13,18],smallest:3,smart:11,softwar:8,solei:2,solut:[6,7],solvabl:8,some:[2,3,5,7,8,11,13,15,16,18,20,23,24],somehow:[11,18],someth:[2,10,11,18],sometim:11,somewher:[11,20],sort:[3,5,11,15,18],sort_:3,sourc:[0,1,3,18,20,21,22,23,24],space:[6,22],span:6,spawn:18,special:[7,11,20],specif:[0,4],specifi:[11,15,24],speed:14,spell:[5,16],sphinx:[20,23],spirit:[0,1,16],split:[5,18,24],sqr:[3,8,9,12,19],sqrt:[3,9,18,24],squar:[3,9,18,21],stack:[0,1,3,6,7,9,11,12,13,14,15,16,17,19,20,21,22,24],stack_effect:18,stack_effect_com:18,stack_to_str:[17,23],stacki:18,stackjoytyp:[18,24],stackstarjoytyp:18,stage:16,stai:[0,1],stand:[4,5],standard:[8,11],star:[16,18,24],stare:11,start:[5,6,7,8,9,11,13,16,18,24],state:[8,20],state_nam:5,statement:[3,5],stdout:[17,18],step:[3,6,8,11,14,18,19,20],still:[5,11,18],stop:11,stopiter:5,storag:[6,11],store:[6,13,18],stori:13,str:[1,5,18,21,22,23],straightforward:[5,7,9,18,20],stream:[6,17,18],stretch:11,string:[1,2,3,8,18,19,20,21,22,23,24],stringi:5,structur:[8,15,16,18,19,20,23],stuck:5,studi:5,stuff:[11,18],stuncon:[3,24],stununcon:[3,24],style:[0,4,18],sub:[10,15,24],subclass:8,subject:[15,19],subsequ:15,subset:[18,24],substitut:[5,11,18,24],subtract:6,subtyp:20,succ:[3,18,24],succe:18,success:9,suck:18,suffic:18,suffici:11,suffix:18,suggest:[4,5,11],suitabl:[3,4,6],sum:[3,7,8,12,13,14,16],sum_:[3,18],summand:6,sumtre:16,suppli:[11,21],support:[8,18,22,23],sure:15,suspect:2,svg:5,swaack:[3,12,14,18,19,24],swap:[3,6,7,8,9,11,13,14,15,16,17,19,24],swon:[3,7,8,13,16,18,19,24],swoncat:[7,8,9,13,16],swuncon:13,sym:5,symbol:[1,2,3,5,15,18,19,20,21],symboljoytyp:[18,24],symmetr:[6,11],symmetri:5,syntact:8,syntax:[8,23],sys:[17,18,23],system:[8,11,15],tabl:[5,18],tag:[5,18],tail:[11,18,20,23],take:[3,5,6,8,9,11,13,15,18,23],talk:[8,11,18,23],target:19,tast:4,tbd:8,tear:13,technic:2,techniqu:[4,19],technolog:2,temporari:19,ten:6,term:[1,2,5,8,9,13,15,18,20,21,23,24],termin:[2,3,5,13],ternari:8,test:[2,3,13],text:[0,1,3,18],text_to_express:[8,17,21],textjoytyp:24,textual:8,than:[0,3,5,6,7,8,9,13,15,16,18,23,24],thei:[2,3,5,6,7,8,11,13,15,18,19,21,23,24],them:[2,3,5,6,7,11,13,15,18,19,20,24],themselv:[15,18,24],theori:[2,3,13,15],therefor:7,thi:[0,1,2,3,4,5,6,7,8,9,12,13,15,16,18,19,20,21,22,23,24],thing:[2,7,11,13,15,18,19,21,23,24],think:[2,6,8,11,13,15,16,18],third:[3,7,8,11,24],thirti:6,those:[2,3,5,11,13,18,20,24],though:[6,15],thought:[8,15],thousand:6,thread:[2,15],three:[2,3,5,6,8,11,12,16,18,20],through:[1,6,8,16,18,19,23,24],thun:[2,3,4,10,13,15],thunder:8,thunk:15,time:[3,5,6,8,9,11,13,15,18,19],titl:18,to_check:5,to_set:11,todai:8,todo:[8,21],togeth:[7,8,15,18,20],token:21,toler:20,too:[5,13,18],tool:[8,18],tooo:18,top:[2,3,8,13,18,22,23],total:6,tower:18,trace:[0,8,12,13,19,20,23],traceprint:22,track:[12,18,19],tracker:0,transform:4,transit:5,translat:[4,12,18],trap:5,travers:[0,20],treasur:0,treat:[0,2,3,13,18,20],treatment:7,tree:[0,8,20],treegrind:20,treestep:[0,20],tri:6,triangl:15,triangular_numb:13,trick:[6,18],tricki:18,trinari:24,trobe:0,trove:0,truediv:24,truthi:[3,8,15,18],tuck:[3,8,18,24],tupl:[3,5,8,18,23,24],turn:[2,3,5,18,24],twice:[11,13],two:[2,3,6,8,9,11,12,13,15,16,17,18,19,20,23,24],txt:3,type:[0,1,4,8,11,13,15,20,21,22,23],type_check:24,typeerror:18,typeless:18,typic:[2,3,12,13],unari:8,unarybuiltinwrapp:3,unbalanc:[11,21],unbound:24,unchang:11,uncompil:18,uncon:[3,7,8,11,13,16,19,24],under:[2,3,8,11],underli:[5,15,18],underscor:18,understand:[0,11],undistinguish:11,undocu:8,unfinish:5,unfortun:23,uni_unifi:24,unicod:18,unif:[18,20],unifi:[17,24],union:5,uniqu:[3,5,11,18],unit:[3,8,13,15,24],univers:[0,8,15,18,24],unlik:15,unnecessari:20,unnecesssari:18,unpack:[2,3,11,23],unpair:6,unquot:[8,16,21],unrol:5,unstack:[3,18],unswon:[3,24],untangl:13,until:[5,7,15],unus:6,unusu:11,unwrap:5,updat:[0,17,20,24],uppercas:5,upward:15,usag:8,use:[0,2,3,4,5,6,7,8,9,10,11,12,13,14,16,19,20,23],used:[3,4,8,11,13,15,18,19,21,23,24],useful:[0,15,18],user:16,uses:[2,5,6,13],using:[7,11,12,13,16,19,24],usual:[0,2,13],util:[0,3,14,17,18],valid:18,valu:[0,1,2,3,6,8,9,12,13,14,15,16,18,20,21,23,24],value_n:11,valueerror:[5,18,23],variabl:[18,20,24],variant:11,variat:[13,15,20],varieti:[4,8],variou:0,vener:23,verbos:4,veri:[0,1,4,5,8,11,23],versa:[2,18],version:[0,1,2,5,7,10,16,19,20],via:8,vice:[2,18],view:[11,20],viewer:[1,8,10,22],vii:20,visibl:18,von:[0,2,3,4,13],waaaai:5,wai:[0,2,3,4,5,6,8,13,14,15,18],wait:15,want:[2,3,6,7,9,11,13,18],warranti:[3,8],wash:8,wast:8,web:23,websit:[0,6],welcom:8,well:[0,4,8,9,11,18,21],went:18,were:[8,18,19],what:[2,3,4,5,8,11,13,15,16,18,22],whatev:[2,3,13,16,23],when:[6,7,8,11,13,15,18,19,21,23,24],where:[2,3,5,8,11,13,18,20,23],whether:13,which:[0,1,5,6,8,9,11,13,15,16,18,19,21,23,24],whole:[2,3,6,13,16,18],whose:7,why:[9,15,16],wiki:11,wikipedia:[0,11,19],wildli:8,wind:8,wire:13,within:[8,11,14,20],without:[2,8,11,12,15,18],won:[11,18,23],word:[0,3,6,8,13,19],work:[0,3,5,6,7,8,9,11,12,13,15,16,19,20,23,24],worker:15,worri:15,worth:6,would:[2,6,7,8,9,11,13,15,18,19,23,24],wrap:[3,8],wrapper:18,write:[4,5,9,11,13,15,16,18,19,20,23],written:[0,1,9,11,14,18,23],wrong:2,wrote:18,xrang:18,yang:18,yeah:15,year:[8,18],yet:[11,15,18,19,24],yield:[2,3,13,18,23,24],yin:[3,20],yin_funct:3,you:[0,2,3,5,6,7,8,10,11,12,13,14,15,16,18,19,22,23],your:[2,3,8,13,18],yourself:[5,8,11],zero:[3,5,11,13,15,16,18,21,23,24],zip:[5,6,18],zip_:3,zipper:[0,20],zstr:19},titles:["Thun 0.2.0 Documentation","Joy Interpreter","Functions Grouped by, er, Function with Examples","Function Reference","Categorical Programming","\u2202RE","Developing a Program in Joy","Using x to Generate Values","Thun: Joy in Python","Newton\u2019s method","No Updates","Treating Trees I: Ordered Binary Trees","Quadratic formula","Recursion Combinators","Replacing Functions in the Dictionary","The Four Fundamental Operations of Definite Action","Treating Trees II: treestep","Type Checking","The Blissful Elegance of Typing Joy","Traversing Datastructures with Zippers","Essays about Programming in Joy","Parsing Text into Joy Expressions","Tracing Joy Execution","Stack or Quote or Sequence or List\u2026","Type Inference of Joy Expressions"],titleterms:{"\u03bb":5,"\u03d5":5,"case":[9,11],"function":[2,3,5,8,9,11,13,14,15,16,18],"long":14,"new":11,"p\u00f6ial":18,"try":5,"void":2,"while":[2,15],Adding:11,One:[7,11],The:[6,8,11,13,15,16,18],There:8,Using:7,With:[5,16],about:20,action:15,add:[2,11],adding:11,address:19,alphabet:5,altern:16,ana:13,analysi:6,anamorph:[2,13],app1:2,app2:2,app3:2,appendix:[11,13,18],appli:15,approxim:9,argument:18,auto:3,averag:2,base:[9,11],binari:[2,11,16],bliss:18,both:11,branch:[2,11,15],brzozowski:5,can:11,cata:13,catamorph:13,categor:4,chatter:2,check:17,child:11,choic:2,clear:2,cleav:[2,15],cmp:11,code:[8,11],combin:[2,11,13,18],comment:18,compact:5,compar:11,comparison:2,compil:[7,18],compile_:18,compos:18,comput:9,con:[2,18],concat:2,conclus:[13,18],consecut:9,continu:8,current:11,datastructur:[5,8,11,19],deal:18,defin:[11,16],definit:[12,15],delabel:18,delet:11,deriv:[5,12,13,16],design:13,determin:19,develop:6,diagram:5,dialect:0,dictionari:14,dip:[2,19],dipd:2,dipdd:2,direco:7,disenstacken:2,distinguish:18,div:2,doc_from_stack_effect:18,document:0,doe:11,down_to_zero:2,drive:5,drop:2,dup:[2,18],dupd:2,dupdip:2,effect:18,eleg:18,els:11,empti:11,enstacken:2,equal:11,essai:20,euler:[6,7],eval:8,even:7,exampl:[2,8,11,13,16,17],execut:22,explor:5,express:[5,8,21,24],extract:16,factori:13,fail:17,fibonacci:7,filter:6,find:[9,11,13],finish:15,finit:5,first:[2,6,15,18],five:7,flatten:2,flexibl:16,floordiv:2,formula:12,found:11,four:[13,15],fsm:5,fulmin:15,fun:13,fundament:15,further:6,gcd:2,gener:[3,5,6,7,9],genrec:2,get:[11,16],getitem:2,given:16,greater:11,group:2,handl:15,have:[11,16],help:2,highest:11,host:0,how:[6,7],hybrid:18,hylo:13,hylomorph:13,identifi:18,ift:[2,15],iii:18,implement:[5,18],indic:0,infer:[18,24],inferenc:18,inform:0,infra:[2,19],integ:6,interest:7,interlud:11,intern:21,interpret:[1,8,18],item:19,iter:[6,11],joi:[0,1,3,6,8,13,18,19,20,21,22,23,24],join:15,just:6,kei:11,kind:15,languag:0,larger:5,least_fract:2,left:11,less:11,let:[5,6],letter:5,librari:[3,8,18],like:11,list:[2,23],literari:8,littl:6,logic:[2,18],loop:[2,8,15],lower:11,lshift:2,machin:5,make:[7,9],mani:6,map:[2,15],match:5,math:2,memoiz:5,method:9,min:2,miscellan:2,mod:2,modifi:18,modulu:2,more:11,most:11,mul:[2,18],multipl:[6,7,18],must:11,name:12,neg:2,newton:9,next:9,node:11,non:11,now:11,nullari:2,nulli:5,number:[13,18],one:8,onli:8,oper:15,order:[11,16],osdn:0,other:15,our:11,out:5,over:2,pack:6,pam:[2,15],para:13,paradigm:18,parallel:15,parameter:[11,16],pars:[2,21],parser:[8,21],part:18,pass:8,path:19,pattern:13,per:11,polytyp:24,pop:[2,18],popd:2,popop:2,pow:2,power:7,pred:2,predic:[6,9,11,16],pretty_print:22,primit:13,primrec:2,print:8,problem:[6,7],process:11,product:2,program:[4,6,12,16,20],progress:18,project:[0,6,7],pure:8,put:[11,12,16],python:[8,14,18],quadrat:12,quick:0,quot:[2,23],rang:[2,6,13],range_to_zero:2,read:8,recur:[9,11],recurs:[11,13,16],redefin:[11,16],refactor:[6,11],refer:3,regular:[5,8],reimplement:16,relabel:18,rem:2,remaind:2,remov:2,render:6,repl:8,replac:[11,14],repres:[5,18],represent:5,reset:7,rest:[2,18],revers:[2,5,17],right:[11,19],rightmost:11,roll:[2,18],rolldown:2,rollup:2,rshift:2,rule:[5,18],run:[2,7],second:[2,18],select:2,sequenc:[7,15,18,23],set:[9,11],shorter:14,should:8,shunt:2,simpl:18,simplest:6,size:[2,14],sourc:11,special:[13,18],sqr:[2,18],sqrt:[2,12],stack:[2,8,18,23],start:0,state:5,step:[2,13,16],straightforward:12,stream:5,string:5,structur:11,style:8,sub:[2,11],subtyp:18,succ:2,sum:[2,6],swaack:2,swap:[2,18],swon:2,swoncat:2,symbol:[8,13],tabl:0,tail:13,take:2,term:[6,7,16],ternari:2,text:21,than:11,them:12,thi:11,third:[2,18],three:7,thun:[0,8],time:[2,7],togeth:[11,12,16],token:8,toler:9,trace:[14,22],traceprint:8,trampolin:5,travers:[11,16,19],treat:[11,16],tree:[11,16,19],treegrind:16,treestep:16,triangular:13,truediv:2,truthi:2,tuck:2,two:[5,7],type:[17,18,24],unari:2,unbound:18,uncon:[2,18],unif:17,unifi:18,unit:2,unnecessari:6,unquot:2,unstack:2,updat:[10,18],use:18,util:[22,23,24],valu:[7,11],variabl:12,variat:7,version:[6,11,14,18],view:8,vii:18,within:9,word:2,work:[17,18],write:12,xor:2,yin:18,zero:7,zip:2,zipper:19}}) \ No newline at end of file +Search.setIndex({docnames:["index","joy","lib","library","notebooks/Categorical","notebooks/Derivatives_of_Regular_Expressions","notebooks/Developing","notebooks/Generator_Programs","notebooks/Intro","notebooks/Newton-Raphson","notebooks/NoUpdates","notebooks/Ordered_Binary_Trees","notebooks/Quadratic","notebooks/Recursion_Combinators","notebooks/Replacing","notebooks/The_Four_Operations","notebooks/Treestep","notebooks/TypeChecking","notebooks/Types","notebooks/Zipper","notebooks/index","parser","pretty","stack","types"],envversion:52,filenames:["index.rst","joy.rst","lib.rst","library.rst","notebooks/Categorical.rst","notebooks/Derivatives_of_Regular_Expressions.rst","notebooks/Developing.rst","notebooks/Generator_Programs.rst","notebooks/Intro.rst","notebooks/Newton-Raphson.rst","notebooks/NoUpdates.rst","notebooks/Ordered_Binary_Trees.rst","notebooks/Quadratic.rst","notebooks/Recursion_Combinators.rst","notebooks/Replacing.rst","notebooks/The_Four_Operations.rst","notebooks/Treestep.rst","notebooks/TypeChecking.rst","notebooks/Types.rst","notebooks/Zipper.rst","notebooks/index.rst","parser.rst","pretty.rst","stack.rst","types.rst"],objects:{"joy.joy":{joy:[1,1,1,""],repl:[1,1,1,""],run:[1,1,1,""]},"joy.library":{"void":[3,1,1,""],BinaryBuiltinWrapper:[3,1,1,""],DefinitionWrapper:[3,2,1,""],FunctionWrapper:[3,1,1,""],SimpleFunctionWrapper:[3,1,1,""],UnaryBuiltinWrapper:[3,1,1,""],add_aliases:[3,1,1,""],app1:[3,1,1,""],app2:[3,1,1,""],app3:[3,1,1,""],b:[3,1,1,""],branch:[3,1,1,""],choice:[3,1,1,""],clear:[3,1,1,""],cmp_:[3,1,1,""],concat_:[3,1,1,""],cond:[3,1,1,""],dip:[3,1,1,""],dipd:[3,1,1,""],dipdd:[3,1,1,""],divmod_:[3,1,1,""],drop:[3,1,1,""],dupdip:[3,1,1,""],floor:[3,1,1,""],genrec:[3,1,1,""],getitem:[3,1,1,""],help_:[3,1,1,""],i:[3,1,1,""],id_:[3,1,1,""],infer_:[3,1,1,""],infra:[3,1,1,""],initialize:[3,1,1,""],inscribe:[3,1,1,""],inscribe_:[3,1,1,""],loop:[3,1,1,""],map_:[3,1,1,""],max_:[3,1,1,""],min_:[3,1,1,""],parse:[3,1,1,""],pm:[3,1,1,""],pred:[3,1,1,""],remove:[3,1,1,""],reverse:[3,1,1,""],select:[3,1,1,""],sharing:[3,1,1,""],shunt:[3,1,1,""],sort_:[3,1,1,""],sqrt:[3,1,1,""],step:[3,1,1,""],succ:[3,1,1,""],sum_:[3,1,1,""],take:[3,1,1,""],times:[3,1,1,""],unique:[3,1,1,""],unstack:[3,1,1,""],warranty:[3,1,1,""],words:[3,1,1,""],x:[3,1,1,""],yin_functions:[3,1,1,""],zip_:[3,1,1,""]},"joy.library.DefinitionWrapper":{add_def:[3,3,1,""],add_definitions:[3,3,1,""],parse_definition:[3,3,1,""]},"joy.parser":{ParseError:[21,4,1,""],Symbol:[21,2,1,""],text_to_expression:[21,1,1,""]},"joy.utils":{generated_library:[3,0,0,"-"],pretty_print:[22,0,0,"-"],stack:[23,0,0,"-"],types:[24,0,0,"-"]},"joy.utils.generated_library":{ccons:[3,1,1,""],cons:[3,1,1,""],dup:[3,1,1,""],dupd:[3,1,1,""],dupdd:[3,1,1,""],first:[3,1,1,""],first_two:[3,1,1,""],fourth:[3,1,1,""],over:[3,1,1,""],pop:[3,1,1,""],popd:[3,1,1,""],popdd:[3,1,1,""],popop:[3,1,1,""],popopd:[3,1,1,""],popopdd:[3,1,1,""],rest:[3,1,1,""],rolldown:[3,1,1,""],rollup:[3,1,1,""],rrest:[3,1,1,""],second:[3,1,1,""],stack:[3,1,1,""],stuncons:[3,1,1,""],stununcons:[3,1,1,""],swaack:[3,1,1,""],swap:[3,1,1,""],swons:[3,1,1,""],third:[3,1,1,""],tuck:[3,1,1,""],uncons:[3,1,1,""],unit:[3,1,1,""],unswons:[3,1,1,""]},"joy.utils.pretty_print":{TracePrinter:[22,2,1,""]},"joy.utils.pretty_print.TracePrinter":{go:[22,5,1,""],viewer:[22,5,1,""]},"joy.utils.stack":{concat:[23,1,1,""],expression_to_string:[23,1,1,""],iter_stack:[23,1,1,""],list_to_stack:[23,1,1,""],pick:[23,1,1,""],stack_to_string:[23,1,1,""]},"joy.utils.types":{AnyJoyType:[24,2,1,""],BooleanJoyType:[24,2,1,""],CombinatorJoyType:[24,2,1,""],FloatJoyType:[24,2,1,""],FunctionJoyType:[24,2,1,""],IntJoyType:[24,2,1,""],JoyTypeError:[24,4,1,""],KleeneStar:[24,2,1,""],NumberJoyType:[24,2,1,""],StackJoyType:[24,2,1,""],SymbolJoyType:[24,2,1,""],TextJoyType:[24,2,1,""],compilable:[24,1,1,""],compile_:[24,1,1,""],compose:[24,1,1,""],delabel:[24,1,1,""],doc_from_stack_effect:[24,1,1,""],infer:[24,1,1,""],meta_compose:[24,1,1,""],poly_compose:[24,1,1,""],reify:[24,1,1,""],relabel:[24,1,1,""],type_check:[24,1,1,""],uni_unify:[24,1,1,""]},"joy.utils.types.BooleanJoyType":{accept:[24,6,1,""]},"joy.utils.types.FloatJoyType":{accept:[24,6,1,""]},"joy.utils.types.IntJoyType":{accept:[24,6,1,""]},"joy.utils.types.KleeneStar":{kind:[24,6,1,""]},"joy.utils.types.StackJoyType":{accept:[24,6,1,""]},"joy.utils.types.TextJoyType":{accept:[24,6,1,""]},joy:{joy:[1,0,0,"-"],library:[3,0,0,"-"],parser:[21,0,0,"-"]}},objnames:{"0":["py","module","Python module"],"1":["py","function","Python function"],"2":["py","class","Python class"],"3":["py","classmethod","Python class method"],"4":["py","exception","Python exception"],"5":["py","method","Python method"],"6":["py","attribute","Python attribute"]},objtypes:{"0":"py:module","1":"py:function","2":"py:class","3":"py:classmethod","4":"py:exception","5":"py:method","6":"py:attribute"},terms:{"05s":5,"0b11100111011011":6,"23rd":18,"5bkei":11,"\u03b4":5,"\u03b5":9,"abstract":[8,11],"boolean":[2,3,8,11,15],"break":[5,8,18],"byte":[5,6],"case":[2,3,13,15,16,18,23],"char":5,"class":[3,5,8,18,21,22,23,24],"default":[3,7,11,23],"export":[3,21],"final":[2,11,13],"float":[3,8,18,19,21,24],"function":[0,1,4,6,7,10,12,17,19,20,21,22,23,24],"g\u00e9rard":19,"goto":5,"import":[2,5,6,7,9,11,12,13,14,16,17,18,19],"int":[5,7,8,13,18,19,21,23,24],"long":[11,18,20],"new":[2,3,5,7,8,10,13,14,18,24],"p\u00f6ial":20,"p\u00f6ial06typingtool":18,"public":10,"return":[1,3,5,6,8,11,13,14,15,16,18,21,22,23,24],"static":[2,10],"super":18,"switch":[2,18],"throw":[11,24],"true":[2,3,5,6,13,15,18,24],"try":[7,9,12,13,16,17,18,20],"void":[0,3],"while":[3,5,8,11,18,21,23],AND:[5,18],Adding:[8,14,20],And:[5,6,7,9,11,13,15,18,19,23],But:[0,4,6,7,8,11,14,18],CPS:8,For:[2,3,11,13,14,18,20,23,24],Its:3,NOT:5,Not:18,One:[2,8,15,18,20],REs:5,TOS:[2,3],That:[6,11],The:[0,1,2,3,4,5,7,9,10,12,19,20,21,23,24],Then:[2,3,11,12,13,18],There:[5,12,13,15,16,18,23],These:[15,18,20,23,24],Use:[3,9,13],Used:15,Using:[0,9,11,20],With:[9,13,18,20,24],_1000:18,__add__:18,__builtin__:24,__call__:5,__class__:18,__eq__:18,__ge__:18,__hash__:18,__init__:[5,18],__main__:18,__radd__:18,__repr__:18,__str__:22,_and:5,_compaction_rul:5,_con:5,_dictionari:18,_ge:18,_infer:18,_interpret:18,_log:18,_log_it:18,_names_for:18,_or:5,_templat:5,_to_str:18,_tree_add_:11,_tree_add_e:[11,24],_tree_add_p:11,_tree_add_r:11,_tree_add_t:11,_tree_delete_:11,_tree_delete_clear_stuff:[11,24],_tree_delete_del:11,_tree_delete_r0:[11,24],_tree_delete_r1:11,_tree_delete_rightmost:11,_tree_delete_w:11,_tree_get_:[11,24],_tree_get_p:11,_tree_get_r:11,_tree_get_t:11,_tree_iter_order_curr:11,_tree_iter_order_left:11,_tree_iter_order_r:11,_tree_iter_order_right:11,_tree_t:11,_treestep_0:16,_treestep_1:16,_uniqu:18,_within_b:9,_within_p:9,_within_r:9,a10001:18,a10002:18,a10003:18,a10004:18,abbrevi:16,abl:[5,15,18,24],about:[0,8,11,15,18,19,23],abov:[0,5,6,9,11,13,15,18],abs:9,absolut:8,accept:[1,2,3,5,6,7,8,11,12,14,15,16,18,19,24],accord:5,accordingli:[11,15],accumul:6,act:[5,24],action:[0,8,14,18,19,20],actual:[2,6,8,11,15,18],adapt:20,add:[3,5,6,7,8,14,18,22,24],add_alias:3,add_def:3,add_definit:[3,11,16],added:[4,11],adding:[10,18],addit:[0,2,3,6,8,13,14,16],address:20,adjust:11,advantag:18,affect:[3,15],after:[5,6,7,8,13,15,18,24],afterward:8,again:[2,3,6,8,11,13,18,24],against:[18,24],aggreg:19,ahead:18,aka:[5,8,19,24],albrecht:0,algorithm:[5,8,18],alia:[3,24],alias:[3,8],align:[8,22],all:[3,5,6,7,8,11,13,14,15,16,18,22,24],alloc:18,allow:[10,11,15],almost:11,along:[5,8,13,18,24],alphabet:[3,20],alreadi:[5,9,14,18,19],also:[0,5,6,8,11,15,18,23,24],alter:[5,18],altern:[4,18,24],although:[4,11],altogeth:7,alwai:[6,10,13,15],amend:15,among:18,amort:11,analysi:[4,20],anamorph:[8,20],ani:[4,5,6,8,10,11,15,18,19,21,24],annual:8,anonym:11,anoth:[5,11,15,18,23,24],anyhow:[15,18],anyjoytyp:[18,24],anymor:18,anystarjoytyp:18,anyth:[2,3,5,8,18,24],apart:18,api:10,app1:3,app2:[3,8,12,13,14,15],app3:[3,15],app:8,appear:[2,4,5,6,11,24],append:18,appendix:20,appli:[2,3,6,7,11,13,18,24],applic:7,approach:6,appropri:5,approxim:20,archiv:0,aren:19,arg:[2,3],argument:[2,3,8,9,12,13,20,22,23],arithmet:2,ariti:[2,15],around:[6,18,21,23],arrang:16,arriv:[7,16],arrow:5,articl:[0,4,7,13],ascii:5,ascii_lowercas:5,ask:[4,7,18],aspect:0,assembl:5,assert:[5,18],assign:[15,23],associ:11,assum:9,asterisk:16,asterix:[18,24],asyncron:15,attack:8,attempt:[0,1,3,18],attribut:3,attributeerror:18,author:18,auto:[0,18,24],automat:[4,15,18,24],auxiliari:[5,16],avail:[0,18,24],averag:[8,14],avoid:[11,24],awai:[11,18],awar:2,awkward:[11,13,18],azur:20,back:[11,18],backtrack:24,backward:[10,11,12,16],bad:18,bag:8,banana:13,bar:15,barb:13,base:[0,2,3,10,13,16,18],basestr:24,basic:[2,3,8,11],basicconfig:[17,18],becaas:5,becaus:[2,3,5,8,11,15,16,18,19,23,24],becom:[11,16,23],becuas:18,been:[5,9,10,11,18,19],befor:[5,7,8,11],begin:[11,16],behavior:[10,16,24],behaviour:[0,1,18,24],behind:15,being:[0,15,24],below:[2,3,5,6,7,11,18,19],bespok:8,best:0,better:[6,11,13,18],between:[0,6,24],beyond:7,biannual:8,bin:5,binari:[0,7,8,20],binary_search_tre:11,binarybuiltinwrapp:3,bind:8,bingo:19,bit:[5,6,7,11,18],blank:21,bliss:[0,20],block:6,bodi:[2,3,5,8,11,15],body_text:3,booktitl:18,bool:[13,18,24],booleanjoytyp:24,borrow:[8,18],both:[2,6,8,12,13,14,15,18,23],bottom:7,bounce_to:5,bracket:[8,18,21],branch:[3,5,6,7,13,18,20,24],branch_fals:18,branch_tru:18,breakpoint:8,bring:[6,8,18],bruijn:18,brutal:15,brzozowski:[18,20],brzozowskian:5,btree:[11,16],buck:11,bug:[0,8],build:[7,8,12,13,19,23],built:[12,18],bundl:[2,3,13],burgeon:8,calculu:4,call:[1,2,5,8,10,11,13,15,18,22,23],caller:[11,18],can:[0,2,3,4,5,6,7,8,9,10,12,13,14,15,16,18,19,20,21,23,24],cancel:15,cannot:[17,18,21],captur:8,card:8,care:[6,23],carefulli:19,carri:[7,11,24],cartesian:4,catamorph:20,categor:[0,20],categori:[4,15],ccc:4,ccon:[3,11,17,18,24],cell:[13,18],certain:[8,23],certainli:11,chain:[3,15],chang:[2,10,11,18,19],charact:[5,19],chat:8,chatter:[0,18],check:[0,7,9,18,20,24],child:16,choic:[3,13],choos:10,chop:12,chose:5,cinf:11,circl:5,circuit:4,cite_not:11,classmethod:3,claus:[3,18],clean:18,clear:[3,6,8],clear_stuff:11,cleav:[8,12,14],close:[0,1,4],clunki:[6,18],clv:15,cmp:[3,16,20],cmp_:3,code:[0,1,4,5,12,13,15,18,20,24],codireco:[7,9],collaps:13,collect:[4,5,7,8,18],collis:24,combin:[0,3,6,7,8,9,12,15,16,19,20,24],combinatorjoytyp:[18,24],come:[8,11,18],command:[8,11,18],comment:[15,24],common:[2,6,15],compar:[3,4,5,18],comparison:[0,11],compat:15,compel:4,compil:[2,3,4,5,8,11,14,15,20,24],compile_:24,complement:5,complet:[3,4],complex:[3,15,18,19,24],complic:18,compos:[5,24],composit:[18,24],compostit:18,compound:11,comput:[2,4,5,6,8,12,15,18,24],con:[3,5,6,7,8,9,11,12,13,15,16,19,23,24],conal:[4,15],concat:[3,7,8,15,16,18,23],concat_:3,concaten:[0,5],concatin:[0,3,5,23],concern:15,conclus:20,concurr:2,cond:[3,11],condit:[3,8],confer:18,conflict:[11,18,24],consecut:20,consid:[5,6,7,11,13,16,18,19],consist:[2,7,8,15,16],constant:11,constitu:13,construct:[15,18],consum:[15,18],contain:[0,2,3,5,7,8,13,18,21],content:18,context:2,conting:11,continu:[0,5,13,18,19],control:8,conveni:[4,15,18],convent:15,convers:18,convert:[13,14,16,18,21,23],cool:11,copi:[2,3,6,11,13,15,16,17,20],copyright:8,correspond:[4,15],could:[2,4,5,6,8,10,11,15,18,19],couldn:15,count:[3,18],counter:[6,18],coupl:16,cours:[6,11,18],cover:18,cpu:15,crack:11,crash:11,creat:[0,2,3,6,9,11,15,18],creativ:18,crude:[11,18,21,24],cruft:18,curent:24,current:[2,3,8,13,15,16,18,19,22,24],curri:5,custom:10,cycl:[6,7],cython:8,d010101:5,d0101:5,d01:5,d10:5,d_compact:5,dai:8,data:[2,3,5,13],datastructur:[0,2,13,18,20,21,23],datatyp:23,ddididi:19,deal:[0,5,11,15],dealt:18,debugg:18,decid:11,declar:18,decor:3,decoupl:13,decrement:3,deduc:[6,18],deeper:0,deepli:4,def:[3,5,8,13,14,18,23],defaultdict:[5,18],defi:3,defin:[2,3,4,5,6,7,8,9,10,12,13,14,15,18,19,20],definit:[0,2,3,6,7,8,10,11,13,16,18,20,24],definitionwrapp:[3,11,13,16],defint:15,del:17,delabel:24,deleg:8,delet:20,deliber:18,demo:18,demonstr:4,depend:[3,11,13,15],deposit:16,depth:[18,24],dequot:13,der:11,deriv:[2,3,6,8,9,11,18,20],derv:5,describ:[3,4,5,11,13,15,16,18,21,24],descript:[6,8],descriptor:18,design:[2,3,11,15,20],desir:[8,16],destin:5,destruct:11,detail:[8,11,18],detect:[5,7,11,13,18],determin:20,develop:[0,7,8,18,20],diagram:6,dialect:1,dict:[1,3,5,18,24],dictionari:[0,1,3,8,18,20],did:18,differ:[0,4,6,9,11,12,13,15,23],differenti:4,difficult:18,difficulti:15,dig:[11,19],digit:6,digraph:5,dinfrirst:[8,18,24],dip:[3,6,7,8,9,11,12,13,14,15,16,18,20,24],dipd:[3,7,8,11,12,13,15,18,19,24],dipdd:[3,11],direco:20,direct:8,directli:[6,15,16,18,23],disappear:[2,5,18,24],discard:[3,7,9,11,13],disciplin:11,disctionari:1,disenstacken:8,disk:8,displac:2,displai:18,distiguish:18,distribut:15,ditch:11,div:[3,8,18,24],dive:16,divis:11,divmod:[3,24],divmod_:[3,18],doc:[2,3,8,18,24],doc_from_stack_effect:[17,24],docstr:18,document:[18,20,21,23],doe:[0,1,3,4,5,7,8,14,15,18,20,22,24],doesn:[6,10,11,15,16,18,23],doing:[4,6,8,15,18,19],domain:[4,18],don:[5,6,8,11,18,24],done:[2,6,8,10,18],dooooc:18,door:8,dot:[5,22],doubl:[3,5,6,8,18],doublecircl:5,down:[2,5,9,13,19,24],down_to_zero:8,dozen:8,draft:[4,10],dream:8,drive:[7,9],driven:6,driver:[5,7],drop:[3,11],dudipd:8,due:18,dup:[3,6,7,8,9,11,12,13,15,17,19,23,24],dupd:[3,18,24],dupdd:[3,24],dupdip:[3,6,11,12,13],duplic:[3,11,13],durat:2,dure:[2,13],each:[2,3,4,5,6,8,13,14,15,16,18,22,24],easi:[0,11,16,18,19],easier:[3,11,15],easili:4,eat:5,edit:20,effect:[2,3,5,8,15,19,20,24],effici:[7,14,19],efg:18,either:[1,2,3,5,11,13,18],elabor:18,eleg:[0,5,8,11,15,20],element:2,elif:18,elimin:[5,18],elliott:[4,15],els:[2,3,5,13,15,18],else_:18,embed:[4,11,19],emit:18,empti:[3,5,8,16,18,23,24],encapsul:8,enclos:8,encod:7,encount:18,end:[5,6,11,13,16,18,23],endless:7,enforc:[2,8],engend:8,enough:[5,8,13,22,24],enstacken:[7,8,18],enter:[3,8,24],enter_guard:18,entir:23,entri:[3,19,22],enumer:18,epsilon:9,equal:[3,6,16,23],equat:[8,9],equival:15,ergo:[5,11],err:[11,17],error:[8,18,21],essai:0,establish:18,etc:[3,16,18,19,21],euler:20,euro:18,eval:[0,18],evalu:[1,2,3,8,9,11,12,13,14,15,16,18],event:15,eventu:[15,18],ever:18,everi:[1,7,15],everybodi:15,everyth:[3,5,11,12,15,18],evolv:10,examin:13,exampl:[0,3,5,6,18,20,21,23,24],exce:7,except:[5,8,11,17,18,21,24],execut:[0,1,2,3,8,13,14,15,16,18,19,23,24],exend:18,exercis:[5,11],exist:[4,11,18],expand:11,expect:[2,3,15,16,18,23,24],experi:[8,16],explain:18,explan:8,explor:[8,18],express:[0,1,2,3,4,11,13,14,18,19,20,22,23],expression_to_str:[18,23],extend:18,extra:[6,7],extract:[11,12,20],extrem:8,extrememli:8,f_g:18,f_in:18,f_out:18,f_python:18,facet:0,facil:8,fact:21,factor:[2,6,8,11,18],factori:20,fail:[2,3,11,20,21,24],fail_fail:3,fairli:18,fake:5,fall:18,fals:[2,3,5,6,13,15,18,24],falsei:18,far:[9,11,13,18,24],fascin:0,favorit:15,fear:[11,18],few:[6,8,9,12,15,18],fewer:[3,8],fg_in:18,fg_out:18,fib:7,fib_gen:7,fibonacci:20,figur:[2,3,11,13,18],filter:11,fin:6,find:[2,3,5,6,7,15,16,18,20],finder:9,fine:[0,5,6,11,18,24],finite_state_machin:5,first:[3,5,7,8,9,11,12,13,14,16,19,20,24],first_two:[3,11,24],fit:[6,8],five:[6,8,20],fix:[2,3,5,13,18,24],fixm:[5,18],flag:[15,18],flatten:[8,16,18],flesh:5,flexibl:20,floatjoytyp:[18,24],floatstarjoytyp:18,floor:3,floordiv:[6,24],flow:8,follow:[0,2,3,5,8,10,13,15,16,18,19,24],foo:[8,10,11,15,18],foo_ii:10,fork:15,form:[2,3,4,5,6,7,13,16,18,23],forman:8,format:[17,18,20,22],formula:[0,6,20],forth:[8,18],forum:0,forward:18,found:8,four:[0,2,3,6,7,8,11,20],fourteen:6,fourth:[2,3,11,13,24],fractal:8,fraction0:8,fraction:[2,8],frame:13,framework:8,free:[4,8,11],freeli:2,from:[0,1,2,3,5,6,7,8,9,11,12,13,14,15,16,17,18,19,20,23],from_:5,front:[2,3,13],frozenset:5,fulin:15,full:6,fun:[5,20],func:18,functionjoytyp:[18,24],functionwrapp:3,functool:5,fundament:[0,20],funtion:11,further:[9,18,20],futur:15,g_in:18,g_out:18,garbag:8,gari:11,gcd:8,gener:[0,2,4,13,15,18,20,23,24],generated_librari:3,genrec:[3,8,11,13,15,16,18],geometr:6,get:[2,4,5,6,7,8,12,13,18,20],getch:5,getitem:3,getrecursionlimit:23,getsourc:8,ghc:4,give:[4,6,11,13,16,18,23],given:[2,3,6,7,9,11,13,15,18,19,20],global:[17,18],glue:8,goe:24,going:[5,11,12,15,16,18,19],good:[6,11,18],grab:18,grammar:21,grand:8,graph:15,graphic:5,graphviz:5,great:[0,8,18,20],greater:23,grind:18,group:0,grow:5,gsra:9,guard:[11,18,24],had:[5,6,19],haiku:8,half:[6,18,19],hallmark:15,hand:[5,8,14,18,20],handi:[9,18],handl:[11,18,23,24],happen:[8,18],happi:5,hard:[5,18,19],hardwar:4,has:[0,2,5,7,8,9,10,11,13,15,18,19,23],hasattr:18,hash:18,haskel:4,have:[2,3,5,6,7,8,9,10,13,14,15,18,19,20,23,24],haven:24,head:23,heh:18,help:[8,11,13,18],help_:3,helper:[3,5],herd:8,here:[5,6,7,11,16,18,19,24],hide:11,hierarchi:18,higher:[5,8,11,18],highli:8,hij:5,histori:[18,22,24],hit:5,hmm:[5,11],hoist:3,hold:[6,18],hood:11,hope:[0,6,8,20],hopefulli:13,host:20,how:[0,4,5,9,11,13,18,19,20],howev:[13,14,15,18],html:[2,3,7,12,13,20],http:11,huet:19,huge:11,hugh:[9,16],human:8,hybrid:24,hylomorph:20,hypothet:2,id_:3,idea:[4,6,8,18],ident:[3,5,13,18,24],if_not_empti:11,ift:[3,11,13,16,18,24],ignor:[1,3,11,18],iii:20,illustr:[5,13],imagin:[5,15,19],imap:18,imit:[5,16],immedi:[5,13],immut:[5,8,11],imper:13,implement:[0,1,2,3,4,8,10,11,13,14,15,20,24],implementaion:15,implicit:8,improv:18,includ:[4,11,15,16,18,24],inclus:6,incom:23,incompat:10,incorpor:12,increas:6,increment:[3,4,6,10,15],indetermin:24,index:[0,8,18,23],indexerror:23,indic:[15,16,18,24],ineffici:18,infer:[0,3,17],infer_:3,inferenc:24,info:[17,18],inform:[3,5,18,24],infra:[3,7,8,11,12,14,15,16,18,20,24],infrastructur:3,initi:[2,3,5,8,9,11,18],inlin:11,inner:18,inproceed:18,input:[1,9,15,17,18,24],input_:5,inscrib:3,inscribe_:3,insert:18,insight:13,inspect:8,inspect_stack:18,instal:0,instanc:18,instanti:[4,22],instead:[5,6,7,11,13,18,19,23,24],instruct:5,integ:[2,3,8,13,16,18,21],integr:3,intend:[0,8],interact:[8,20],interest:[0,6,11,18,20],interfer:15,interlud:20,intermedi:13,intern:[0,18,22,23],interpret:[0,4,10,14,21,22,24],interrupt:8,intersect:5,interspers:15,interv:[4,6],intjoytyp:[18,24],introduc:10,introduct:0,intstarjoytyp:18,intuit:18,invalid:24,invari:3,invent:18,involv:18,ipf:8,isinst:[5,18],isn:[5,11,19],issubclass:18,item:[2,3,8,11,13,15,16,18,20,23],iter:[1,3,5,8,13,15,16,18,20,23],iter_stack:[14,23],iteritem:[5,18],itertool:[5,18],its:[0,1,2,3,4,6,8,11,13,15,16,18,23],itself:[0,2,8,11,15,18,24],j05cmp:[2,3,13],jaanu:18,jmp:5,job:[15,20],john:[9,16],joi:[2,4,10,11,12,14,15,17],join:[5,18],joypi:[8,19],joytypeerror:[17,24],jump:5,jump_from:5,junk:18,jupyt:20,just:[0,2,3,5,7,8,10,11,13,15,16,18,19],juxtaposit:15,keep:[5,11,12,15,18,19],kei:[5,16,20],kevin:0,key_n:11,keyerror:[5,11,18],kind:[2,4,8,11,13,16,18,24],kinda:18,kleen:[16,18,24],kleenestar:[18,24],kleffner:18,know:[6,11,18],knowledg:18,known:[4,15],kstar:5,l_kei:11,l_left:11,l_right:11,l_valu:11,label:[5,18],lambda:[4,5,18],languag:[4,5,8,10,11,14,18],larg:[5,18],larger:[20,23],largest:3,last:[6,11,13,18],lastli:7,later:[5,8,16,18],law:2,lazi:18,lazili:9,lcm:6,lead:[5,8,18,24],leaf:11,lean:8,learn:0,least:[2,6,13,18,23],least_fract:8,leav:[6,15],left:[5,8,12,13,15,16,18,19,22,23,24],leftov:13,legend:5,len:[5,18],length:[3,6,23],lens:13,less:[6,7,8,13,18,23],let:[7,9,11,12,13,16,18,19,20],letter:18,level:[4,5,11,17,18],librari:[0,5,14],like:[2,3,5,6,8,15,16,18,20,21,24],limit:[18,24],line:[3,8,11,12,18,22,24],linear:23,link:[0,5,18],linux:0,list:[0,3,5,6,8,9,11,13,15,16,18,19,22,24],list_to_stack:[18,23],liter:[1,11,16,18,19,21],literatur:18,littl:[5,7,11,15,18,20],live:20,lkei:16,load:[6,8],local:18,locat:2,locu:22,log:[17,18],log_2:11,logic:[0,6,20],longer:[11,18],look:[1,5,7,8,9,11,12,15,18],lookup:8,loop:[0,1,3,5,6,18,20,24],lose:18,lot:[5,8,11,18,19],love:6,low:[4,5],lower:6,lowercas:[5,18],lowest:11,lshift:24,machin:[0,20],machineri:[11,18],macro:8,made:[0,8,15,18,19],magic:18,mai:[2,13,15],mail:0,main:[0,3,8,12,15,18,19],mainloop:10,maintain:19,major:10,make:[2,3,4,6,8,11,13,14,15,16,18,19,20],make_gener:9,make_graph:5,manfr:[0,2,3,4,13],mani:[0,5,8,18],manipul:18,manner:12,map:[1,3,5,6,8,10,13,16,18],map_:3,marker:8,mask:[6,7],match:[0,1,18,20],materi:0,math:[0,8,9,11,12,18],mathemat:8,matter:[6,9,11,16],max_:3,maximum:3,mayb:[11,18],mean:[3,4,6,8,9,11,13,16,18,23,24],meant:[8,11,13,16],mem:5,member:[2,3,13],memo:5,mental:8,mention:2,mercuri:0,mess:18,messag:[17,18],meta:[8,11,14],meta_compos:[18,24],method:[0,3,8,18,20,22],midpoint:6,might:[4,5,7,11,18],mike:11,million:7,min_:3,mind:18,minimum:3,minor:11,minu:3,mirror:0,miscellan:0,mismatch:18,mix:[8,18],mod:3,mode:18,model:[4,8],modern:0,modif:[7,18],modifi:[8,11,19],modul:[0,1,3,8,18,21],modulu:[8,24],moment:18,month:8,more:[0,3,4,5,6,7,8,9,13,14,15,16,18,21,23,24],most:[5,18,24],mostli:0,move:[5,11],movement:2,much:[5,6,7,11,13,18],muck:11,mul:[3,8,12,17,19,22,24],multi:3,multipl:[20,24],must:[2,3,6,10,13,15,16,18,21],myself:18,n10001:18,n10002:18,n10003:18,n1001:18,n1002:18,n1003:18,name:[1,3,5,8,10,11,13,18,19,20,21,23,24],narr:18,natur:[5,6,7,11,18],navig:19,nearli:18,neat:11,neato:18,necessarili:18,need:[2,3,6,7,9,10,11,13,15,18],neg:[3,12,24],neither:[15,18],ness:5,nest:[3,8,11,19],network:8,never:[5,10,13],new_def:18,new_f:18,new_fo:18,new_kei:11,new_valu:11,newton:[0,20],next:[5,6,15,16,18,24],nice:[0,5,13,23],niether:2,node:[5,16,20],node_kei:11,node_valu:11,non:[5,16,18,24],none:[1,3,18,24],nope:16,nor:5,normal:15,notat:[8,11],note:[2,5,6,9,11,13,15,18,23],notebook:[6,7,8,18,19,20],notebook_preambl:[2,6,7,9,11,12,13,14,16,18,19],noth:[2,11,15],notic:6,now:[5,6,7,8,13,14,16,18,20],nth:[3,23],nullari:[8,11,15,18,24],number:[1,2,3,6,7,9,15,23,24],numberjoytyp:[18,24],numberstarjoytyp:18,numer:18,object:[5,18,21],observ:6,obviou:7,obvious:18,occur:11,odd:[6,7],off:[2,3,6,7,12,18,19],often:[5,15],old:[2,14],old_k:11,old_kei:11,old_valu:11,omg:5,omit:[13,18,21],onc:[3,5,10,11],one:[2,3,5,6,7,11,13,15,16,18,22,23,24],ones:[5,7,18],onli:[2,3,5,6,11,13,15,18,19,23,24],onto:[1,2,3,8,13,23],open:[8,18],oper:[0,3,5,8,11,13,20,23],oppos:18,optim:11,option:[1,8,11,18,23],orchestr:15,order:[0,2,3,8,13,15,17,18,20,23],org:[0,11],origin:[0,1,2,3,11,19],other:[0,2,3,4,5,8,11,13,16,18,23,24],otherwis:[3,5,6,7,11,16,18,24],our:[5,6,7,8,9,13,16,18],out:[2,3,4,6,7,8,9,11,12,13,15,18,19,20],outcom:16,outlin:5,output:[5,9,13,15,17,18,24],outsid:4,over:[3,4,6,7,8,9,11,12,15,16,18,20,24],overhaul:18,overview:18,own:[11,18],pack:23,packag:[0,8],page:[0,11,18,23],pair:[2,3,6,7,11,18],palidrom:6,palindrom:6,pam:8,paper:[4,8,13,15,19],paradigm:20,parallel:[2,20],paramet:[1,2,3,13,14,21,22,23],parameter:20,paramorph:13,parenthes:[11,23],pariti:7,pars:[0,3,5,8],parse_definit:3,parseerror:21,parser:[0,17,18],part:[2,3,9,13,16,20],partial:[5,18],particular:19,pass:[0,5,11,18,22,24],patch:5,path:[5,18,20],pattern:[5,6,15,16,20],pe1:[6,7],pe2:7,pearl:19,pend:[3,8,13,18,19,22],peopl:20,per:[8,16],perfectli:15,perform:[5,15,18],perhap:7,period:8,permit:[15,18,23],permut:18,persist:[3,11],phase:2,phi:5,pick:[6,7,15,23],pickl:8,pictur:11,piec:13,pip:0,place:[3,6,8,18],plai:0,plu:3,plug:[7,13,16],point:[4,5,8,11,13,15],pointless:2,poly_compos:24,polytyp:[0,17,18],pool:15,pop:[3,5,6,7,8,11,13,14,16,17,23,24],popd:[3,8,9,11,14,15,18,24],popdd:[3,7,12,18,24],popop:[3,6,7,8,9,11,16,18,24],popopd:[3,24],popopdd:[3,24],posit:[3,6,8,13],possibilit:11,possibl:[11,16,18,20],post:8,poswrd:18,potenti:15,pow:24,power:[8,18],pprint:5,pragmat:6,preambl:9,preceed:15,precis:[0,1],pred:[3,18,24],predic:[2,3,5,7,13,15,24],prefix:[18,22],preliminari:5,present:18,preserv:[4,16],pretti:[9,11,12,15,16,18,22,23],pretty_print:0,previou:[8,15],prime:9,primit:[2,3,18,20],primrec:[3,7,8,9,13],print:[0,1,2,3,5,17,18,22,23,24],probabl:[7,8,11,18],problem:[8,18,20],proc_curr:11,proc_left:11,proc_right:11,proce:[6,24],process:[5,8,16,18,22],produc:[6,11,13,16,18],product:[5,7,8,17,18],program:[0,2,3,7,8,9,11,13,15,18,19,24],programm:[15,18],progress:15,project:20,prolog:18,promis:15,prompt:8,proper:[2,3,13,15,24],properti:0,provid:[0,3,4,8,15,18,24],pun:[0,8],punctuat:18,pure:[0,5],puriti:8,purpos:8,push:[2,3,8,13,19,23],put:[1,2,7,8,15,18,20,23],pypi:0,python:[0,2,3,5,11,13,15,19,20,21,23,24],quadrat:[0,20],queri:[11,16],query_kei:16,queu:13,quit:[0,16],quot:[0,3,7,8,11,12,13,15,16,18,19,22,24],quotat:[2,3,13],quotient:3,r_kei:11,r_left:11,r_right:11,r_valu:11,rais:[5,11,18,21,23],rang:[5,8,18],range_revers:13,range_to_zero:8,ranger:13,ranger_revers:13,rankdir:5,raphson:9,rather:[6,8,13,16],ratio:8,reach:[5,6,7,13],read:[0,1,6,7,11,18,19],readabl:14,reader:[5,11],readi:18,real:11,realiz:[4,11],rearrang:[2,3,11,18],reason:[6,8,15,18],rebuild:[16,19],rec1:[2,3,13],rec2:[2,3,13],recogn:21,recombin:15,record:[8,22],recur:[13,18],recurs:[0,2,3,5,7,8,9,15,18,20,23],recus:8,redefin:20,redistribut:[3,8],redo:5,reduc:[2,18],redund:23,refactor:[8,10],refer:[0,2],referenti:15,reflect:15,regard:15,regist:2,regular:[18,20,21],reifi:[17,24],reimplement:[15,20],relabel:24,relat:[5,18],releas:10,remain:[2,8,10,18],remaind:[3,9],rememb:5,remind:18,remov:[3,11,18,23],render:20,repeat:6,repeatedli:6,repetit:5,repl:[0,1],replac:[0,2,3,7,12,13,15,16,18,19,20,23],repositori:0,repr:[5,18],repres:[2,8,11,15,21,22,24],represent:[23,24],reprod:7,repurpos:18,requir:[15,18,23],res:18,research:18,resembl:8,resolut:15,resourc:[3,15],respect:[5,6,15],rest:[3,6,7,8,11,13,19,20,23,24],rest_two:11,restart:3,restor:2,result:[1,2,3,5,6,11,12,13,15,16,18,19],resum:8,retir:2,retri:8,reus:[11,18],revers:[3,6,7,13,18,19,20,23],revisit:18,rewrit:[3,8,18],rewritten:8,rid:11,right:[7,8,12,16,18,20,22,23,24],rightest:11,rightmost:6,rigor:15,risk:18,rkei:16,rob:18,roll:[3,9,11,16],roll_dn:18,rolldown:[3,17,18,24],rollup:[3,18,24],root:[3,9,12],round:18,row:5,rrest:[3,17,18,24],rshift:24,rule:[15,20],run:[0,1,3,6,8,9,11,12,13,15,16,18,19],runtim:15,runtimeerror:23,sai:[5,7,11,12,16,18],same:[2,4,6,11,15,18,23],sandwich:[2,3,13],save:[2,5,6,8],scan:3,scanner:[8,21],scenario:19,scope:[7,11],search:[0,11],sec:[18,24],second:[3,8,11,13,16,23,24],section:13,see:[0,5,7,8,9,10,12,13,14,18,19,22],seem:[0,6,8,16,18,24],seen:[18,19,24],select:3,self:[5,15,18],semant:[2,3,8,10,11,15,18],semi:8,send:8,sens:[0,2,6,18,19],separ:[8,15,18,21],seq:18,sequenc:[0,1,2,3,6,8,11,13,14,19,20,21,24],sequence_to_stack:18,seri:[6,7,11,19],ses:18,set:[2,3,5,13,18,20],seven:[6,7],sever:[0,4,8,13],shape:[5,15],share:[3,8],shelf:2,shew:5,shift:[6,7],shorter:20,shorthand:11,should:[2,3,5,6,11,13,15,18],shouldn:8,show:[4,15,18,19],shunt:[3,19],side:[5,11,17,18,24],sign:3,signatur:24,signifi:[8,11],similar:[11,16,18],simon:8,simpl:[5,8,13,23,24],simplefunctionwrapp:[3,14,18],simpler:16,simplest:[18,20],simpli:4,simplifi:[6,11,19],sinc:[2,6,11,18],singl:[3,7,8,14,15,18,21,24],singleton:5,situ:11,situat:11,six:[6,7,8],sixti:[6,7],size:[5,8,20],skeptic:8,skip:18,slight:9,slightli:[11,13,18],smallest:3,smart:11,softwar:8,solei:2,solut:[6,7],solvabl:8,some:[2,3,5,7,8,11,13,15,16,18,20,23,24],somehow:[11,18],someth:[2,10,11,18],sometim:11,somewher:[11,20],sort:[3,5,11,15,18],sort_:3,sourc:[0,1,3,18,20,21,22,23,24],space:[6,22],span:6,spawn:18,special:[7,11,20],specif:[0,4],specifi:[11,15,24],speed:14,spell:[5,16],sphinx:[20,23],spirit:[0,1,16],split:[5,18,24],sqr:[3,8,9,12,19],sqrt:[3,9,18,24],squar:[3,9,18,21],stack:[0,1,3,6,7,9,11,12,13,14,15,16,17,19,20,21,22,24],stack_effect:18,stack_effect_com:18,stack_to_str:[17,23],stacki:18,stackjoytyp:[18,24],stackstarjoytyp:18,stage:16,stai:[0,1],stand:[4,5],standard:[8,11],star:[16,18,24],stare:11,start:[5,6,7,8,9,11,13,16,18,24],state:[8,20],state_nam:5,statement:[3,5],stdout:[17,18],step:[3,6,8,11,14,18,19,20],still:[5,11,18],stop:11,stopiter:5,storag:[6,11],store:[6,13,18],stori:13,str:[1,5,18,21,22,23],straightforward:[5,7,9,18,20],stream:[6,17,18],stretch:11,string:[1,2,3,8,18,19,20,21,22,23,24],stringi:5,structur:[8,15,16,18,19,20,23],stuck:5,studi:5,stuff:[11,18],stuncon:[3,24],stununcon:[3,24],style:[0,4,18],sub:[10,15,24],subclass:8,subject:[15,19],subsequ:15,subset:[18,24],substitut:[5,11,18,24],subtract:6,subtyp:20,succ:[3,18,24],succe:18,success:9,suck:18,suffic:18,suffici:11,suffix:18,suggest:[4,5,11],suitabl:[3,4,6],sum:[3,7,8,12,13,14,16],sum_:[3,18],summand:6,sumtre:16,suppli:[11,21],support:[8,18,22,23],sure:15,suspect:2,svg:5,swaack:[3,12,14,18,19,24],swap:[3,6,7,8,9,11,13,14,15,16,17,19,24],swon:[3,7,8,13,16,18,19,24],swoncat:[7,8,9,13,16],swuncon:13,sym:5,symbol:[1,2,3,5,15,18,19,20,21],symboljoytyp:[18,24],symmetr:[6,11],symmetri:5,syntact:8,syntax:[8,23],sys:[17,18,23],system:[8,11,15],tabl:[5,18],tag:[5,18],tail:[11,18,20,23],take:[3,5,6,8,9,11,13,15,18,23],talk:[8,11,18,23],target:19,tast:4,tbd:8,tear:13,technic:2,techniqu:[4,19],technolog:2,temporari:19,ten:6,term:[1,2,5,8,9,13,15,18,20,21,23,24],termin:[2,3,5,13],ternari:8,test:[2,3,13],text:[0,1,3,18],text_to_express:[8,17,21],textjoytyp:24,textual:8,than:[0,3,5,6,7,8,9,13,15,16,18,23,24],thei:[2,3,5,6,7,8,11,13,15,18,19,21,23,24],them:[2,3,5,6,7,11,13,15,18,19,20,24],themselv:[15,18,24],theori:[2,3,13,15],therefor:7,thi:[0,1,2,3,4,5,6,7,8,9,12,13,15,16,18,19,20,21,22,23,24],thing:[2,7,11,13,15,18,19,21,23,24],think:[2,6,8,11,13,15,16,18],third:[3,7,8,11,24],thirti:6,those:[2,3,5,11,13,18,20,24],though:[6,15],thought:[8,15],thousand:6,thread:[2,15],three:[2,3,5,6,8,11,12,16,18,20],through:[1,6,8,16,18,19,23,24],thun:[2,3,4,10,13,15],thunder:8,thunk:15,time:[3,5,6,8,9,11,13,15,18,19],titl:18,to_check:5,to_set:11,todai:8,todo:[8,21],togeth:[7,8,15,18,20],token:21,toler:20,too:[5,13,18],tool:[8,18],tooo:18,top:[2,3,8,13,18,22,23],total:6,tower:18,trace:[0,8,12,13,19,20,23],traceprint:22,track:[12,18,19],tracker:0,transform:4,transit:5,translat:[4,12,18],trap:5,travers:[0,20],treasur:0,treat:[0,2,3,13,18,20],treatment:7,tree:[0,8,20],treegrind:20,treestep:[0,20],tri:6,triangl:15,triangular_numb:13,trick:[6,18],tricki:18,trinari:24,trobe:0,trove:0,truediv:24,truthi:[3,8,15,18],tuck:[3,8,18,24],tupl:[3,5,8,18,23,24],turn:[2,3,5,18,24],twice:[11,13],two:[2,3,6,8,9,11,12,13,15,16,17,18,19,20,23,24],txt:3,type:[0,1,4,8,11,13,15,20,21,22,23],type_check:24,typeerror:18,typeless:18,typic:[2,3,12,13],unari:8,unarybuiltinwrapp:3,unbalanc:[11,21],unbound:24,unchang:11,uncompil:18,uncon:[3,7,8,11,13,16,19,24],under:[2,3,8,11],underli:[5,15,18],underscor:18,understand:[0,11],undistinguish:11,undocu:8,unfinish:5,unfortun:23,uni_unifi:24,unicod:18,unif:[18,20],unifi:[17,24],union:5,uniqu:[3,5,11,18],unit:[3,8,13,15,24],univers:[0,8,15,18,24],unlik:15,unnecessari:20,unnecesssari:18,unpack:[2,3,11,23],unpair:6,unquot:[8,16,21],unrol:5,unstack:[3,18],unswon:[3,24],untangl:13,until:[5,7,15],unus:6,unusu:11,unwrap:5,updat:[0,17,20,24],uppercas:5,upward:15,usag:8,use:[0,2,3,4,5,6,7,8,9,10,11,12,13,14,16,19,20,23],used:[3,4,8,11,13,15,18,19,21,23,24],useful:[0,15,18],user:16,uses:[2,5,6,13],using:[7,11,12,13,16,19,24],usual:[0,2,13],util:[0,3,14,17,18],valid:18,valu:[0,1,2,3,6,8,9,12,13,14,15,16,18,20,21,23,24],value_n:11,valueerror:[5,18,23],variabl:[18,20,24],variant:11,variat:[13,15,20],varieti:[4,8],variou:0,vener:23,verbos:4,veri:[0,1,4,5,8,11,23],versa:[2,18],version:[0,1,2,5,7,10,16,19,20],via:8,vice:[2,18],view:[11,20],viewer:[1,8,10,22],vii:20,visibl:18,von:[0,2,3,4,13],waaaai:5,wai:[0,2,3,4,5,6,8,13,14,15,18],wait:15,want:[2,3,6,7,9,11,13,18],warranti:[3,8],wash:8,wast:8,web:23,websit:[0,6],welcom:8,well:[0,4,8,9,11,18,21],went:18,were:[8,18,19],what:[2,3,4,5,8,11,13,15,16,18,22],whatev:[2,3,13,16,23],when:[6,7,8,11,13,15,18,19,21,23,24],where:[2,3,5,8,11,13,18,20,23],whether:13,which:[0,1,5,6,8,9,11,13,15,16,18,19,21,23,24],whole:[2,3,6,13,16,18],whose:7,why:[9,15,16],wiki:11,wikipedia:[0,11,19],wildli:8,wind:8,wire:13,within:[8,11,14,20],without:[2,8,11,12,15,18],won:[11,18,23],word:[0,3,6,8,13,19],work:[0,3,5,6,7,8,9,11,12,13,15,16,19,20,23,24],worker:15,worri:15,worth:6,would:[2,6,7,8,9,11,13,15,18,19,23,24],wrap:[3,8],wrapper:18,write:[4,5,9,11,13,15,16,18,19,20,23],written:[0,1,9,11,14,18,23],wrong:2,wrote:18,xrang:18,yang:18,yeah:15,year:[8,18],yet:[11,15,18,19,24],yield:[2,3,13,18,23,24],yin:[3,20],yin_funct:3,you:[0,2,3,5,6,7,8,10,11,12,13,14,15,16,18,19,22,23],your:[2,3,8,13,18],yourself:[5,8,11],zero:[3,5,11,13,15,16,18,21,23,24],zip:[5,6,18],zip_:3,zipper:[0,20],zstr:19},titles:["Thun 0.2.0 Documentation","Joy Interpreter","Functions Grouped by, er, Function with Examples","Function Reference","Categorical Programming","\u2202RE","Developing a Program in Joy","Using x to Generate Values","Thun: Joy in Python","Newton\u2019s method","No Updates","Treating Trees I: Ordered Binary Trees","Quadratic formula","Recursion Combinators","Replacing Functions in the Dictionary","The Four Fundamental Operations of Definite Action","Treating Trees II: treestep","Type Checking","The Blissful Elegance of Typing Joy","Traversing Datastructures with Zippers","Essays about Programming in Joy","Parsing Text into Joy Expressions","Tracing Joy Execution","Stack or Quote or Sequence or List\u2026","Type Inference of Joy Expressions"],titleterms:{"\u03bb":5,"\u03d5":5,"case":[9,11],"function":[2,3,5,8,9,11,13,14,15,16,18],"long":14,"new":11,"p\u00f6ial":18,"try":5,"void":2,"while":[2,15],Adding:11,One:[7,11],The:[6,8,11,13,15,16,18],There:8,Using:7,With:[5,16],about:20,action:15,add:[2,11],adding:11,address:19,alphabet:5,altern:16,ana:13,analysi:6,anamorph:[2,13],app1:2,app2:2,app3:2,appendix:[11,13,18],appli:15,approxim:9,argument:18,auto:3,averag:2,base:[9,11],binari:[2,11,16],bliss:18,both:11,branch:[2,11,15],brzozowski:5,can:11,cata:13,catamorph:13,categor:4,chatter:2,check:17,child:11,choic:2,clear:2,cleav:[2,15],cmp:11,code:[8,11],combin:[2,11,13,18],comment:18,compact:5,compar:11,comparison:2,compil:[7,18],compile_:18,compos:18,comput:9,con:[2,18],concat:2,conclus:[13,18],consecut:9,continu:8,current:11,datastructur:[5,8,11,19],deal:18,defin:[11,16],definit:[12,15],delabel:18,delet:11,deriv:[5,12,13,16],design:13,determin:19,develop:6,diagram:5,dialect:0,dictionari:14,dip:[2,19],dipd:2,dipdd:2,direco:7,disenstacken:2,distinguish:18,div:2,doc_from_stack_effect:18,document:0,doe:11,down_to_zero:2,drive:5,drop:2,dup:[2,18],dupd:2,dupdip:2,effect:18,eleg:18,els:11,empti:11,enstacken:2,equal:11,essai:20,euler:[6,7],eval:8,even:7,exampl:[2,8,11,13,16,17],execut:22,explor:5,express:[5,8,21,24],extract:16,factori:13,fail:17,fibonacci:7,filter:6,find:[9,11,13],finish:15,finit:5,first:[2,6,15,18],five:7,flatten:2,flexibl:16,floordiv:2,formula:12,found:11,four:[13,15],fsm:5,fulmin:15,fun:13,fundament:15,further:6,gcd:2,gener:[3,5,6,7,9],genrec:2,get:[11,16],getitem:2,given:16,greater:11,group:2,handl:15,have:[11,16],help:2,highest:11,host:0,how:[6,7],hybrid:18,hylo:13,hylomorph:13,identifi:18,ift:[2,15],iii:18,implement:[5,18],indic:0,infer:[18,24],inferenc:18,inform:0,infra:[2,19],integ:6,interest:7,interlud:11,intern:21,interpret:[1,8,18],item:19,iter:[6,11],joi:[0,1,3,6,8,13,18,19,20,21,22,23,24],join:15,just:6,kei:11,kind:15,languag:0,larger:5,least_fract:2,left:11,less:11,let:[5,6],letter:5,librari:[3,8,18],like:11,list:[2,23],literari:8,littl:6,logic:[2,18],loop:[2,8,15],lower:11,lshift:2,machin:5,make:[7,9],mani:6,map:[2,15],match:5,math:2,memoiz:5,method:9,min:2,miscellan:2,mod:2,modifi:18,modulu:2,more:11,most:11,mul:[2,18],multipl:[6,7,18],must:11,name:12,neg:2,newton:9,next:9,node:11,non:11,now:11,nullari:2,nulli:5,number:[13,18],one:8,onli:8,oper:15,order:[11,16],osdn:0,other:15,our:11,out:5,over:2,pack:6,pam:[2,15],para:13,paradigm:18,parallel:15,parameter:[11,16],pars:[2,21],parser:[8,21],part:18,pass:8,path:19,pattern:13,per:11,polytyp:24,pop:[2,18],popd:2,popop:2,pow:2,power:7,pred:2,predic:[6,9,11,16],pretty_print:22,primit:13,primrec:2,print:8,problem:[6,7],process:11,product:2,program:[4,6,12,16,20],progress:18,project:[0,6,7],pure:8,put:[11,12,16],python:[8,14,18],quadrat:12,quick:0,quot:[2,23],rang:[2,6,13],range_to_zero:2,read:8,recur:[9,11],recurs:[11,13,16],redefin:[11,16],refactor:[6,11],refer:3,regular:[5,8],reimplement:16,relabel:18,rem:2,remaind:2,remov:2,render:6,repl:8,replac:[11,14],repres:[5,18],represent:5,reset:7,rest:[2,18],revers:[2,5,17],right:[11,19],rightmost:11,roll:[2,18],rolldown:2,rollup:2,rshift:2,rule:[5,18],run:[2,7],second:[2,18],select:2,sequenc:[7,15,18,23],set:[9,11],shorter:14,should:8,shunt:2,simpl:18,simplest:6,size:[2,14],sourc:11,special:[13,18],sqr:[2,18],sqrt:[2,12],stack:[2,8,18,23],start:0,state:5,step:[2,13,16],straightforward:12,stream:5,string:5,structur:11,style:8,sub:[2,11],subtyp:18,succ:2,sum:[2,6],swaack:2,swap:[2,18],swon:2,swoncat:2,symbol:[8,13],tabl:0,tail:13,take:2,term:[6,7,16],ternari:2,text:21,than:11,them:12,thi:11,third:[2,18],three:7,thun:[0,8],time:[2,7],togeth:[11,12,16],token:8,toler:9,trace:[14,22],traceprint:8,trampolin:5,travers:[11,16,19],treat:[11,16],tree:[11,16,19],treegrind:16,treestep:16,triangular:13,truediv:2,truthi:2,tuck:2,two:[5,7],type:[17,18,24],unari:2,unbound:18,uncon:[2,18],unif:17,unifi:18,unit:2,unnecessari:6,unquot:2,unstack:2,updat:[10,18],use:18,util:[22,23,24],valu:[7,11],variabl:12,variat:7,version:[6,11,14,18],view:8,vii:18,within:9,word:2,work:[17,18],write:12,xor:2,yin:18,zero:7,zip:2,zipper:19}}) \ No newline at end of file