From cb81efc544d64ccc8aeeacaeb70c8fd2233a8471 Mon Sep 17 00:00:00 2001 From: cynic Date: Mon, 19 Sep 2022 16:40:16 -0400 Subject: [PATCH] don't try to execute variable markers before they're subbed --- lib.py | 4 +++- test.klambda | 12 ++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/lib.py b/lib.py index a2ab857..b61f55a 100644 --- a/lib.py +++ b/lib.py @@ -54,7 +54,9 @@ def execute(program): ) _fixarr(subs) #print("abba", ctx, subs) - if ctx[0][1] == "id": + if ctx[0][1][0] == "$": + return subs + elif ctx[0][1] == "id": return subs[1] if len(subs[1:]) == 1 else subs[1:] elif ctx[0] == _ident("miracle"): return _box(getattr(sys.modules[_destr(subs[1])], _destr(subs[2]))(*[i[1] for i in _fixarr(subs[3])])) diff --git a/test.klambda b/test.klambda index 7f2272f..597d285 100644 --- a/test.klambda +++ b/test.klambda @@ -21,4 +21,16 @@ INCLUDE:./lib/aids.klambda ) ) +(defun loop + (id all + (id id spit ($1)) + (id id cond (id id id = $1 $2) + $1 + (id id id loop (id id id id + $1 1) $2) + ) + ) +) + +(loop 0 5) + (thesis) \ No newline at end of file