From 6f430ec89d3bd1dbed091429e70389e58dbf72b1 Mon Sep 17 00:00:00 2001 From: Devyn Cairns Date: Wed, 16 Aug 2023 19:21:13 -0700 Subject: [PATCH] redefine fn to construct a more optimized expression --- stage2/04-functional.lsp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/stage2/04-functional.lsp b/stage2/04-functional.lsp index a4d70e9..39eb244 100644 --- a/stage2/04-functional.lsp +++ b/stage2/04-functional.lsp @@ -2,10 +2,16 @@ ; allows you to much more nicely define a function - just provide arg list ; and destructuring will happen automatically (define fn (proc def-args def-scope - (proc args scope - (eval - (concat (assoc (car def-args) (eval-list scope args)) def-scope) - (cadr def-args))))) + (eval () + (concat (quote (proc args scope)) + (cons + (list eval + (list concat + (list assoc + (list quote (car def-args)) + (quote (eval-list scope args))) + (list quote def-scope)) + (list quote (cadr def-args))) ()))))) ; functional left fold (define left-fold (fn (f val list)