function - 如何在另一个函数中使用嵌套函数作为球拍语言的参数?
问题描述
我想在定义中创建函数:
(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
推荐阅读
- c - 将 CSV 解析为动态分配的结构数组 (ANSI 89)
- java - 在 maven 插件和调用 maven 项目 pom 之间共享属性
- .net - .NET Standard 2.0 - 使用哪个 Microsoft.Extensions.DependencyInjection.Abstractions 版本
- javascript - 如何将来自 json API 响应的数据存储到 ReactJS 中的数组中?
- python - 如何按字典的值对字典进行排序
- xpath - Xpath is correct but no result after scraping
- reactjs - Creatable in React-Select and Typescript fails with error
- c# - Linq Join does not seem to have data of the complete join
- swift - 尝试更改个人资料照片时应用程序崩溃
- oracle - 在游标中使用 for 循环和别名检索变量