OSDN Git Service

I think the real solution is to "not do that" as it were.
authorSimon Forman <sforman@hushmail.com>
Sun, 28 Nov 2021 23:03:47 +0000 (15:03 -0800)
committerSimon Forman <sforman@hushmail.com>
Sun, 28 Nov 2021 23:03:47 +0000 (15:03 -0800)
Unquoted symbols on the stack are verboten.

debugger.py
docs/Zipper.ipynb

index 710055a..44bd6a0 100644 (file)
@@ -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))
 
 
 
index 6b98413..83d126f 100644 (file)
    "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",
   },
   {
    "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": [],