[plt-scheme] typed scheme intro

From: Sam Tobin-Hochstadt (samth at ccs.neu.edu)
Date: Thu Apr 8 16:11:41 EDT 2010

Those are both bugs.  The return type of `mag' should be `Number', as
the untyped version indicates.  I've fixed this in SVN.

sam th

On Thu, Apr 8, 2010 at 3:41 PM, Danny Yoo <dyoo at cs.wpi.edu> wrote:
> I'm trying to run the mag program described in:
>
>    http://docs.plt-scheme.org/ts-guide/quick.html
>
> but it doesn't look quite right: the addition of the squared
> components appears to be missing.
>
> Furthermore, when I do change it to:
>
> (: mag (pt -> Real))
> (define (mag p)
>  (sqrt (+ (sqr (pt-x p))
>           (sqr (pt-y p)))))
>
> I get a type error because I can't convince the type checker that the
> result of the addition will be a positive real.  I worked around by
> doing:
>
> (: mag (pt -> Real))
> (define (mag p)
>  (real-part (sqrt (+ (sqr (pt-x p))
>                           (sqr (pt-y p))))))
>
>
> Am I missing something?
> _________________________________________________
>  For list-related administrative tasks:
>  http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>



-- 
sam th
samth at ccs.neu.edu


Posted on the users mailing list.