So I'm new to Scheme. I'm trying to make a function that defines global functions using a specification of the form ((name: name) (args: args) (body: body)) so for example
(fn-maker '((name: mult5) (x) (* x 5)))
would make it so globally I could call
(mult5 3)
and get 15.
Here's what I have so far:
(define (fn-maker fn-spec)
(let* (spec (map cdr fn-spec))
(name (caar spec))
(args (cadr fn-spec))
(body (caaddr (cdaddr fn-spec))))
(lambda (args)
body)))
The main thing I'm confused on at the moment is how to make lambda use those args. As it stands, lambda creates a new local variable named "args" instead of evaluating the list that is behind args. Is there a way around this? My current thought process is that I should be using some form of let across the list provided by args but I'm not sure what that would look like or even how to go about structuring it.
This is homework so I'm most definitely not looking for code (cheating and all that) but rather a point in the right direction and some critique. Thank you.
Update: To anyone who happens upon this in the future, it is possible to do this code very simply using some clever quoting. No macros needed. Also, as it turns out, eval in Pretty Big evaluates in the global by default.