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
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)
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
## step
## uncons
-
+expr = text_to_expression('[[dip]] [uncons] trace')
+print(test_expr(CD, e=expr))
"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": [],