Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
为什么这个函数只是将一个数字加 1 而完全忽略乘法?
(define (ev n) (local [(define (res l) ( * 2 n))] (+ 1 n)))
......因为你没有res在任何地方打电话。一种local特殊的形式对于定义帮助程序很有用,但仅此而已 -定义它们。如果没有显式调用,它们将什么也不做;另请注意,表达式(* 2 n)乘以n2,但您忽略了l参数。我不确定你打算写什么,也许是这样的?
res
local
(* 2 n)
n
l
(define (ev n) (local [(define (res l) (* 2 l))] (res (+ 1 n)))) (ev 3) => 8