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
精彩评论