Reputation:
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: '(lambda () 100) (no arguments)
Then how can I make `(lambda () 100) as a procedure?
Upvotes: 1
Views: 237
Reputation: 5618
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
Upvotes: 1