[plt-scheme] How to make the following code more clear?
I wish this were the reason. Turns out car and cdr are applicable to
(Listof X) just as much as they are in ML and Haskell. These aren't
type errors but variant errors. I, however, prefer to express the
stronger theorem when the language accommodates it. In this regard,
Chongkai is correct,
-- Matthias
On Oct 13, 2008, at 3:28 PM, Chongkai Zhu wrote:
> Because `largest' doesn't work on empty list.
>
> Chongkai
>
> Eric Tanter wrote:
>>> #lang typed-scheme
>>> [...]
>>> (: largest ((cons α (Listof α)) -> α))
>>> ;; pick the largest value from the list
>>> (define (largest lst)
>>> (foldr max (car lst) (cdr lst)))
>>
>> any reason why you used (cons a (Listof a)) instead of simply
>> (Listof a) in the type signature of largest?
>>
>> -- Éric_________________________________________________
>> For list-related administrative tasks:
>> http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>