typed-racket/typed-racket-test/succeed/do.rkt
2014-12-16 10:07:25 -05:00

18 lines
374 B
Racket
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#lang typed-scheme
(define-type-alias Nb Number)
(let: ([x : Nb 3]) x)
(let ([x '(1 3 5 7 9)])
(let: doloop : Nb
([x : (Listof Nb) x]
[sum : Number 0])
(if (null? x) sum
(doloop (cdr x) (+ sum (car x))))))
(let ((x '(1 3 5 7 9)))
(do: : Nb ((x : (Listof Nb) x (cdr x))
(sum : Number 0 (+ sum (car x))))
((null? x) sum)))