Sebastian Tennant:
Hi all,
An elementary scheme problem from an elementary schemer...
I need to create multiple variable bindings from a list of symbols. The
value of the variables is unimportant. It's the 'names' of the
variables that matter.
In pseudo-scheme code:
(map (lambda (v) (define (eval v) "foo") '(var1 var2 var3)))
Clearly this won't work but I thought perhaps calling a macro in place
of the 'define' would do it, but...
That's a common problem.
Maybe this is one good enough:
(define-macro (define-lotsof names value)
`(begin
,@(map (lambda (name)
`(define ,name ,value))
names)))
(define-lotsof (a b c) "foo")
If not, you may need to play with local-eval or similar.