diff --git a/docs/sphinx_docs/_build/doctrees/environment.pickle b/docs/sphinx_docs/_build/doctrees/environment.pickle index a5d187b..a92d50b 100644 Binary files a/docs/sphinx_docs/_build/doctrees/environment.pickle and b/docs/sphinx_docs/_build/doctrees/environment.pickle differ diff --git a/docs/sphinx_docs/_build/doctrees/joy.doctree b/docs/sphinx_docs/_build/doctrees/joy.doctree index 1511b25..22ae729 100644 Binary files a/docs/sphinx_docs/_build/doctrees/joy.doctree and b/docs/sphinx_docs/_build/doctrees/joy.doctree differ diff --git a/docs/sphinx_docs/_build/doctrees/library.doctree b/docs/sphinx_docs/_build/doctrees/library.doctree index c3155ba..0ad95e9 100644 Binary files a/docs/sphinx_docs/_build/doctrees/library.doctree and b/docs/sphinx_docs/_build/doctrees/library.doctree differ diff --git a/docs/sphinx_docs/_build/doctrees/parser.doctree b/docs/sphinx_docs/_build/doctrees/parser.doctree index 1e0b37e..4083aa6 100644 Binary files a/docs/sphinx_docs/_build/doctrees/parser.doctree and b/docs/sphinx_docs/_build/doctrees/parser.doctree differ diff --git a/docs/sphinx_docs/_build/doctrees/pretty.doctree b/docs/sphinx_docs/_build/doctrees/pretty.doctree index 49a54bd..0b18a48 100644 Binary files a/docs/sphinx_docs/_build/doctrees/pretty.doctree and b/docs/sphinx_docs/_build/doctrees/pretty.doctree differ diff --git a/docs/sphinx_docs/_build/doctrees/stack.doctree b/docs/sphinx_docs/_build/doctrees/stack.doctree index c54b1d9..c335e30 100644 Binary files a/docs/sphinx_docs/_build/doctrees/stack.doctree and b/docs/sphinx_docs/_build/doctrees/stack.doctree differ diff --git a/docs/sphinx_docs/_build/html/_modules/joy/joy.html b/docs/sphinx_docs/_build/html/_modules/joy/joy.html index e0e1647..d240039 100644 --- a/docs/sphinx_docs/_build/html/_modules/joy/joy.html +++ b/docs/sphinx_docs/_build/html/_modules/joy/joy.html @@ -94,11 +94,10 @@ term, expression = expression if isinstance(term, Symbol): - try: - term = dictionary[term] - except KeyError: + if term not in dictionary: raise UnknownSymbolError(term) - stack, expression, dictionary = term(stack, expression, dictionary) + func = dictionary[term] + stack, expression, dictionary = func(stack, expression, dictionary) else: stack = term, stack diff --git a/docs/sphinx_docs/_build/html/_modules/joy/library.html b/docs/sphinx_docs/_build/html/_modules/joy/library.html index df23247..389391f 100644 --- a/docs/sphinx_docs/_build/html/_modules/joy/library.html +++ b/docs/sphinx_docs/_build/html/_modules/joy/library.html @@ -234,9 +234,9 @@ if line.lstrip().startswith('#'): continue name, body = text_to_expression(line) -## if name not in dictionary: -## inscribe(class_(name, body), dictionary) - inscribe(class_(name, body), dictionary) + if name not in dictionary: + inscribe(class_(name, body), dictionary) +## inscribe(class_(name, body), dictionary) # @@ -449,7 +449,8 @@ def remove(S): ''' Expects an item on the stack and a quote under it and removes that item - from the the quote. The item is only removed once. + from the the quote. The item is only removed once. If the list is + empty or the item isn't in the list then the list is unchanged. :: [1 2 3 1] 1 remove @@ -457,10 +458,14 @@ [2 3 1] ''' - (tos, (second, stack)) = S - l = list(iter_stack(second)) - l.remove(tos) - return list_to_stack(l), stack + (item, (quote, stack)) = S + return _remove(item, quote), stack + + +def _remove(item, quote): + try: head, tail = quote + except ValueError: return quote + return tail if head == item else (head, _remove(item, tail))
[docs]@inscribe @@ -816,6 +821,22 @@ return stack, concat(p, concat(q, expression)), dictionary
+
[docs]@inscribe +@FunctionWrapper +def ii(stack, expression, dictionary): + ''' + :: + + ... a [Q] ii + ------------------ + ... Q a Q + + ''' + quote, (a, stack) = stack + expression = concat(quote, (a, concat(quote, expression))) + return stack, expression, dictionary
+ +
[docs]@inscribe @FunctionWrapper def dupdip(stack, expression, dictionary): @@ -1019,32 +1040,32 @@ return stack, concat(then if flag else else_, expression), dictionary
-##@inscribe -##@FunctionWrapper -##def ifte(stack, expression, dictionary): -## ''' -## If-Then-Else Combinator -## :: -## -## ... [if] [then] [else] ifte -## --------------------------------------------------- -## ... [[else] [then]] [...] [if] infra select i -## -## -## -## -## ... [if] [then] [else] ifte -## ------------------------------------------------------- -## ... [else] [then] [...] [if] infra first choice i -## -## -## Has the effect of grabbing a copy of the stack on which to run the -## if-part using infra. -## ''' -## (else_, (then, (if_, stack))) = stack -## expression = (S_infra, (S_first, (S_choice, (S_i, expression)))) -## stack = (if_, (stack, (then, (else_, stack)))) -## return stack, expression, dictionary +
[docs]@inscribe +@FunctionWrapper +def ifte(stack, expression, dictionary): + ''' + If-Then-Else Combinator + :: + + ... [if] [then] [else] ifte + --------------------------------------------------- + ... [[else] [then]] [...] [if] infra select i + + + + + ... [if] [then] [else] ifte + ------------------------------------------------------- + ... [else] [then] [...] [if] infra first choice i + + + Has the effect of grabbing a copy of the stack on which to run the + if-part using infra. + ''' + (else_, (then, (if_, stack))) = stack + expression = (S_infra, (S_first, (S_choice, (S_i, expression)))) + stack = (if_, (stack, (then, (else_, stack)))) + return stack, expression, dictionary
[docs]@inscribe diff --git a/docs/sphinx_docs/_build/html/_modules/joy/utils/pretty_print.html b/docs/sphinx_docs/_build/html/_modules/joy/utils/pretty_print.html index 4c5a225..0a20441 100644 --- a/docs/sphinx_docs/_build/html/_modules/joy/utils/pretty_print.html +++ b/docs/sphinx_docs/_build/html/_modules/joy/utils/pretty_print.html @@ -66,7 +66,7 @@ joy? On each line the stack is printed with the top to the left, then a -bullet symbol,``•``, to represent the current locus of processing, then +bullet symbol, •, to represent the current locus of processing, then the pending expression to the right. ''' # (Kinda clunky and hacky. This should be swapped out in favor of much diff --git a/docs/sphinx_docs/_build/html/genindex.html b/docs/sphinx_docs/_build/html/genindex.html index 1360592..ce6c14b 100644 --- a/docs/sphinx_docs/_build/html/genindex.html +++ b/docs/sphinx_docs/_build/html/genindex.html @@ -201,12 +201,16 @@
  • id_() (in module joy.library)
  • -
  • infra() (in module joy.library) +
  • ifte() (in module joy.library)
  • -
  • initialize() (in module joy.library) +
  • ii() (in module joy.library) +
  • +
  • infra() (in module joy.library)