theshked
03-20-2005, 01:40 PM
Hi,
I'm writing a Scheme interpreter in Scheme, and I've encountered the following problem:
I want to interpret a list of symbols, where the first element is a binary operation, and the next two are arguments. something like: '(+ 1 1).
I defined a list of bindings from symbols to primitives, that looks like this:
(list (list '+ +) (list '- -) (list '* *)....)
and wrote a procdure that searches for the given symbol, and returns the corresponding primitive. say that the search procedure has returned a primitive op. now I want to apply op to the second and third elements in my list.
but when I try to write an expression like (op arg1 arg2), I get an error message saying:
procedure application: expected procedure, given: (#<primitive:+>); arguments were: ...
How do I overcome this?
thanks in advance,
Alan
I'm writing a Scheme interpreter in Scheme, and I've encountered the following problem:
I want to interpret a list of symbols, where the first element is a binary operation, and the next two are arguments. something like: '(+ 1 1).
I defined a list of bindings from symbols to primitives, that looks like this:
(list (list '+ +) (list '- -) (list '* *)....)
and wrote a procdure that searches for the given symbol, and returns the corresponding primitive. say that the search procedure has returned a primitive op. now I want to apply op to the second and third elements in my list.
but when I try to write an expression like (op arg1 arg2), I get an error message saying:
procedure application: expected procedure, given: (#<primitive:+>); arguments were: ...
How do I overcome this?
thanks in advance,
Alan