开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜