如何在另一个函数中使用嵌套函数作为球拍语言中的参数?
How to use nested function in another function as argument in racket language?
我想在定义中创建函数:
(define example
'(
(define (func)
(rectfc 200 0 "blue")
)
)
)
然后将其用作另一个函数的参数
(execute 400 400 example '(func)))
没有(评估)功能。
不需要引用。
#lang racket
(define (run-f args)
(define (add-one n) ; <- defining a function locally
(+ n 1)) ;
(map-f add-one ; <- passing into another function
args))
(define (map-f f args)
(map f ; <- using the function that
args)) ; was passed in
(run-f '(1 2 3))
; = 2 3 4
我想在定义中创建函数:
(define example
'(
(define (func)
(rectfc 200 0 "blue")
)
)
)
然后将其用作另一个函数的参数
(execute 400 400 example '(func)))
没有(评估)功能。
不需要引用。
#lang racket
(define (run-f args)
(define (add-one n) ; <- defining a function locally
(+ n 1)) ;
(map-f add-one ; <- passing into another function
args))
(define (map-f f args)
(map f ; <- using the function that
args)) ; was passed in
(run-f '(1 2 3))
; = 2 3 4