From a040113e65c6340efc9e0931498bc0132138d02c Mon Sep 17 00:00:00 2001 From: cynic Date: Mon, 17 Oct 2022 08:35:27 -0400 Subject: [PATCH] one small step towards satori --- lib.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib.py b/lib.py index f4e8799..d8983e7 100644 --- a/lib.py +++ b/lib.py @@ -58,6 +58,8 @@ def execute(program): if ctx[0] == _ident("defun"): fns[ctx[1]] = ctx[2] return fns[ctx[1]] + elif ctx[0] == _ident("lambda"): + return ("lambda", (ctx[1], ctx[2])) elif ctx[0] == _ident("cond"): return _execute(ctx[2], lids, lfns) if _truthy(_execute(ctx[1], lids, lfns)) else _execute(ctx[3], lids, lfns) @@ -114,14 +116,20 @@ def execute(program): #print(prototype) return _execute(prototype, lids, lfns) else: + #print(f"{subs[0]} is not a valid function") return subs - + elif ctx[0][0] == "lambda": + prototype = ctx[0][1][1] + for idx, arg in enumerate(ctx[0][1][0]): + prototype = _recursereplace(prototype, arg, ctx[1:][idx]) + return _execute(prototype, lids, lfns) else: #print("base", ctx) if type(ctx) == type([]): return list( map(lambda a: _execute(a, lids, lfns), ctx) ) + return ctx idspace = {} funcspace = {}