I think the real solution is to "not do that" as it were.

Unquoted symbols on the stack are verboten.
This commit is contained in:
Simon Forman 2021-11-28 15:03:47 -08:00
parent 89550cdd5f
commit 5d856bf444
2 changed files with 111 additions and 10 deletions

View File

@ -35,7 +35,7 @@ expected_result = '[1 [2 [3 4 625 6] 7] 8]'
expected_result_as_stack = text_to_expression(expected_result) 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. Run the test expression with the defs in ds.
Return the resulting stack as a string or the Return the resulting stack as a string or the
@ -44,7 +44,7 @@ def test_expr(ds):
D = dictionary.copy() D = dictionary.copy()
D.update(ds) D.update(ds)
try: try:
stack, _, _ = joy((), expression, D) stack, _, _ = joy((), e, D)
except Exception as err: except Exception as err:
return err return err
return stack_to_string(stack) return stack_to_string(stack)
@ -202,9 +202,9 @@ del CD['unit']
del CD['unswons'] del CD['unswons']
del CD['x'] del CD['x']
print(test_expr(CD)) ##print(test_expr(CD))
for n in sorted(CD): ##for n in sorted(CD):
print(n) ## print(n)
## ? ## ?
## _step0 ## _step0
## _step1 ## _step1
@ -217,7 +217,8 @@ for n in sorted(CD):
## step ## step
## uncons ## uncons
expr = text_to_expression('[[dip]] [uncons] trace')
print(test_expr(CD, e=expr))

View File

@ -540,12 +540,53 @@
"outputs": [], "outputs": [],
"source": [] "source": []
}, },
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Argh! It is inside `uncons` itself, isn't it!?"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"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", "cell_type": "code",
"execution_count": null, "execution_count": null,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [] "source": [
"uncons"
]
}, },
{ {
"cell_type": "code", "cell_type": "code",
@ -556,10 +597,69 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": 4,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [
"source": [] {
"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", "cell_type": "code",