【发布时间】:2019-12-02 03:05:06
【问题描述】:
我试图从 Little Schemer 书中为这个函数添加类型。
(define rember-fc
(λ(test?)
(λ (a l)
(cond [(null? l) '()]
[(test? a (car l)) (cdr l)]
[else
(cons (car l)
((rember-fc test?) a (cdr l)))]))))
这种类型会导致错误。
(: rember-fc (∀ (a) (-> (-> Any Any Boolean) (-> a (Listof a) (Listof a)))))
这种类型有效。
(: rember-fc (-> (-> Any Any Boolean) (∀ (a) (-> a (Listof a) (Listof a)))))
我想知道为什么这两种类型会导致不同的结果,有什么区别?
【问题讨论】:
标签: types racket typed-racket