| From: Todd O'Bryan (toddobryan at gmail.com) Date: Mon Apr 20 11:23:35 EDT 2009 |
|
Any reason why?
The following doesn't work:
(: ! (Integer -> Integer))
(define (! n)
(cond
[(zero? n) 1]
[else (* n
(! (sub1 n)))]))
but change (sub1 n) to (- n 1) and it works fine.
Also, is there any way to define subtypes? For example, could I define
a "natural-number" type that's limited to non-negative integers?
Thanks,
Todd
P.S. Typed Scheme is fun to play with. :-)
| Posted on the users mailing list. |
|