开发者

How to make it as procedure?

开发者 https://www.devze.com 2023-03-28 09:26 出处:网络
I have the scenario where a function returns an lambda form, and I want to apply the lambda form but failed. Example:

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

精彩评论

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