From 5d856bf444196b5570b0585108b99e26331dba10 Mon Sep 17 00:00:00 2001 From: Simon Forman Date: Sun, 28 Nov 2021 15:03:47 -0800 Subject: [PATCH] I think the real solution is to "not do that" as it were. Unquoted symbols on the stack are verboten. --- debugger.py | 13 ++++--- docs/Zipper.ipynb | 108 ++++++++++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 111 insertions(+), 10 deletions(-) diff --git a/debugger.py b/debugger.py index 710055a..44bd6a0 100644 --- a/debugger.py +++ b/debugger.py @@ -35,7 +35,7 @@ expected_result = '[1 [2 [3 4 625 6] 7] 8]' expected_result_as_stack = text_to_expression(expected_result) -def test_expr(ds): +def test_expr(ds, e=expression): ''' Run the test expression with the defs in ds. Return the resulting stack as a string or the @@ -44,7 +44,7 @@ def test_expr(ds): D = dictionary.copy() D.update(ds) try: - stack, _, _ = joy((), expression, D) + stack, _, _ = joy((), e, D) except Exception as err: return err return stack_to_string(stack) @@ -202,9 +202,9 @@ del CD['unit'] del CD['unswons'] del CD['x'] -print(test_expr(CD)) -for n in sorted(CD): - print(n) +##print(test_expr(CD)) +##for n in sorted(CD): +## print(n) ## ? ## _step0 ## _step1 @@ -217,7 +217,8 @@ for n in sorted(CD): ## step ## uncons - +expr = text_to_expression('[[dip]] [uncons] trace') +print(test_expr(CD, e=expr)) diff --git a/docs/Zipper.ipynb b/docs/Zipper.ipynb index 6b98413..83d126f 100644 --- a/docs/Zipper.ipynb +++ b/docs/Zipper.ipynb @@ -541,18 +541,52 @@ "source": [] }, { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Argh! It is inside `uncons` itself, isn't it!?" + ] + }, + { "cell_type": "code", - "execution_count": null, + "execution_count": 1, "metadata": {}, - "outputs": [], - "source": [] + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [] + } + ], + "source": [ + "clear" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[Q] [dip dip infra dip infra dip infra]" + ] + } + ], + "source": [ + "[Q] [dip dip infra dip infra dip infra]" + ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], - "source": [] + "source": [ + "uncons" + ] }, { "cell_type": "code", @@ -563,6 +597,72 @@ }, { "cell_type": "code", + "execution_count": 4, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[Q] [dip dip infra dip infra dip infra]" + ] + } + ], + "source": [ + "[popdd roll< pop] inscribe" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [] + } + ], + "source": [ + "clear" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[Q] [dip dip infra dip infra dip infra]" + ] + } + ], + "source": [ + "[Q] [dip dip infra dip infra dip infra]" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[Q] dip [dip infra dip infra dip infra]" + ] + } + ], + "source": [ + "uncons" + ] + }, + { + "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], -- 2.11.0