[plt-scheme] In Typed Scheme, type for sub1 doesn't include (Integer -> Integer)
There will be soon, e.g., n in Nat such that even? is true, too. Sam
has been working on this and it should come out soon -- Matthias
On Apr 20, 2009, at 11:23 AM, Todd O'Bryan wrote:
> 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. :-)
> _________________________________________________
> For list-related administrative tasks:
> http://list.cs.brown.edu/mailman/listinfo/plt-scheme