Add unit test for dotted instantiation, and add version of
fold-left/fold-right that explicitly instantiates the recursive call. original commit: 2a7dbe2a80d34abc5097e144b80bda9965546703
This commit is contained in:
parent
8e48f42184
commit
8be54e9a3b
19
collects/tests/typed-scheme/succeed/fold-left-inst.ss
Normal file
19
collects/tests/typed-scheme/succeed/fold-left-inst.ss
Normal file
|
@ -0,0 +1,19 @@
|
|||
#lang typed-scheme
|
||||
|
||||
(: fold-left (All (c a b ...) ((c a b ... b -> c) c (Listof a) (Listof b) ... b -> c)))
|
||||
(define (fold-left f c as . bss)
|
||||
(if (or (null? as)
|
||||
(ormap null? bss))
|
||||
c
|
||||
(apply (inst fold-left c a b ... b) f
|
||||
(apply f c (car as) (map car bss))
|
||||
(cdr as) (map cdr bss))))
|
||||
|
||||
(: fold-right (All (c a b ...) ((c a b ... b -> c) c (Listof a) (Listof b) ... b -> c)))
|
||||
(define (fold-right f c as . bss)
|
||||
(if (or (null? as)
|
||||
(ormap null? bss))
|
||||
c
|
||||
(apply f
|
||||
(apply (inst fold-left c a b ... b) f c (cdr as) (map cdr bss))
|
||||
(car as) (map car bss))))
|
|
@ -577,6 +577,9 @@
|
|||
(-Integer B -Integer . -> . -Integer)
|
||||
. -> . -Integer)]
|
||||
|
||||
[tc-e (plambda: (z x y ...) () (inst map z x y ... y))
|
||||
(-polydots (z x y) ((list ((list z x) (y y) . ->... . z) z (-lst x)) ((-lst y) y) . ->... . (-lst z)))]
|
||||
|
||||
;; error tests
|
||||
[tc-err (#%variable-reference number?)]
|
||||
[tc-err (+ 3 #f)]
|
||||
|
|
Loading…
Reference in New Issue
Block a user