问题描述
我想在定义中创建函数:
(define example
'(
(define (func)
(rectfc 200 0 "blue")
)
)
)
(execute 400 400 example '(func)))
没有(eval)函数。
解决方法
无需引用。
#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