-2
定义功能以下功能的工作原理:使用λ球拍
(define (testfn)
(define (contains sl item) (ormap (λ(x)(equal? item x)) sl))
(if (contains (list 1 2 3) 2) "yes" "no"))
(testfn)
输出:
"yes"
但以下,使用λ符号,并不:
(define (testfn2)
(λ (contains sl item) (ormap (λ(x)(equal? item x)) sl))
(if (contains (list 1 2 3) 2) "yes" "no"))
错误是:
contains: unbound identifier in module in: contains
λ符号可以用来定义可能在多个地方调用的内部(或一般)函数吗?
'λ'是'lambda'的别名,而不是'define'。 –
“λ符号”是小写的希腊字符* lambda *。 – molbdnilo