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
Everyone knows to open a TR reply and do:
> (:print-type expt)
right? It's fun :)
Robby
On Tue, Sep 27, 2016 at 3:40 PM, Vincent St-Amour
wrote:
> You are correct, the implementation of `expt` is not aware of that fact.
>
> However, TR assigns `expt` a type
You are correct, the implementation of `expt` is not aware of that fact.
However, TR assigns `expt` a type after the fact, and so is able to
encode more precise properties.
The particular one under discussion happens to not hold, as Pierpaolo
explained.
Vincent
On Tue, 27 Sep 2016 08:36:43
/i/ forgot about that.
And there you have it: (-> Nonnegative-Real Real Real)
Don’t laugh, but the irony (tragedy) is that I’m using it to implement
some quaternion stuff.
On 27/09/16 14:43, Pierpaolo Bernardi wrote:
> On Tue, Sep 27, 2016 at 3:23 PM, Tim Brown wrote:
>
On Tue, Sep 27, 2016 at 3:23 PM, Tim Brown wrote:
> 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).
What about (expt -1 1/2) ?
--
You received this message because
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. 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
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
7 matches
Mail list logo