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:
Sam Tobin-Hochstadt 2008-06-19 14:59:19 -04:00
parent 8e48f42184
commit 8be54e9a3b
2 changed files with 22 additions and 0 deletions

View 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))))

View File

@ -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)]