On Tue, Sep 27, 2016 at 02:36:43PM +0100, Matthew Eric Bassett wrote:
> I do not believe this is an oversight.  The function expt has type
> signature (-> Number Number Number).  Mathematically, yes, a^b is a real
> when a and b are reals.

not if a is negative and b is one-half.
Or are complex numbers not available?

> But the implementation of expt is not aware of
> it (it is, in principle, possible to do case-by-case types for a
> function, but expt does not appear to take advantage of this).
> 
> Because of this, (expt a b) is a Number, but your function definition
> requires it to be the more restrictive Real.  Since you know that a and
> b are reals, you could probably get away with a cast to Real.
> 
> On 09/27/2016 02:23 PM, Tim Brown wrote:
> > The following snippet:
> > 
> > --------------------------
> > #lang typed/racket
> > (: ** [Real Real -> Real])
> > (define (** a b)
> >   (expt a b))
> > --------------------------
> > 
> > Throws:
> > unsaved editor:5:2: Type Checker: type mismatch expected: Real given: 
> > Number in: (expt a b)
> >   #(67 10)
> > 
> > 
> > I believe (because I can’t think of a counterexample) that
> > (expt Real Real) is never Complex; and therefore expt can be of type
> > (Real Real -> Real).
> > 
> > First off, is the statement above true?
> > 
> > Is there a technical reason why my example HAS TO fall back to
> > (Number Number -> Number)? Or is this simply an oversight?
> > 
> > Regards,
> > 
> > Tim
> > 
> > Version: 6.6.0.4--2016-09-08(-/f) [3m].
> > 
> 
> -- 
> Matthew Eric Bassett | http://mebassett.info
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to racket-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.



-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to