Skip to content

Commit

Permalink
redefine fn to construct a more optimized expression
Browse files Browse the repository at this point in the history
  • Loading branch information
devyn committed Aug 17, 2023
1 parent 24fcdc4 commit 6f430ec
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions stage2/04-functional.lsp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 6f430ec

Please sign in to comment.