开发者

How to make it as procedure?

I have the scenario where a function returns an lambda form, and I want to apply the lambda form but failed. Example:

#lang racket

(define tes (lambda () `(lambda () 100)))
(tes)
((tes))

the result is:

'(lambda () 100)
. . procedure application: expected procedure, given: '(开发者_Python百科lambda () 100) (no arguments)

Then how can I make `(lambda () 100) as a procedure?


If you remove the backquote from the inner lambda expression, it will work. Alternately, you could immediately unquote after the backquote, but that amounts to a noop:

> (define tes (lambda () (lambda () 100)))
> ((tes))
100
> (define tes (lambda () `,(lambda () 100)))
> ((tes))
100
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜