Return an expression that is a mutable object in Scheme?
Hi I am trying to write a function that will return an expression that is mutable and can be used as a procedure.
For example:
(fooeq 1 2)
would return (eq? 1 2)
and
((fooeq 1 2))
would return #f
Is there a way to write an expression that is a symbol that can be converted into a procedure?
EDIT: I got it, thanks for the responses. 开发者_如何学C In case anyone else was wondering it's the (eval p).
I guess you want fooeq
to evaluate to a function:
> (define (fooeq a b)
(lambda () (eq? a b)))
> ((fooeq 1 2))
#f
> ((fooeq 1 1))
#t
>
A function that takes one or more functions as input or outputs a function is known as a higher-order function.
精彩评论