[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [plt-scheme] embarrasing question



In a message dated 5/5/2002 11:47:13 PM Central Daylight Time, caw@cs.mu.oz.au writes:


I'm trying to do this:

(for-each (lambda (sym fn)
                (hash-table-put! *function-table* sym fn))
    '(+ - blurp) '(+ - (lambda (x) (+ x 1))))

with the idea being, obviously, storing the procedure + under the key +, and
the proc to add one to a number under the key blurp.

Equally obviously, it doesn't work


You want to use quasiquote and unquote:
(for-each (lambda (sym fn)
                (hash-table-put! *function-table* sym fn))
    '(+ - blurp) `(,+ ,- ,(lambda (x) (+ x 1))))

Or even just list:
(for-each (lambda (sym fn)
                (hash-table-put! *function-table* sym fn))
    '(+ - blurp) (list + - (lambda (x) (+ x 1))))

Jim