Original-Via: uk.ac.nsf; Wed, 6 Nov 91 20:00:39 GMT
Original-Sender: [EMAIL PROTECTED]
> I would be very much in favour of missing out the >= test in both n+k and
> c*n+k. As Mark says there is no need for a restriction in the latter case.
> In the former, the restriction is only there because of a wish to model
> the Natural Numbers, a data type which is NOT native to Haskell.
>
> Tony
May I then propose yet another (sorry :-) arithmetic pattern: -n;
that matches only negative numbers:
case e0 of {-x -> e; _ -> e';}
= if e0 < 0 then case -(e0) of {x -> e; _ -> e';} else e'
E.g.
abs (-n) = n
abs n = n
x ^ (-n) = error "x^(-n) is undefined."
x ^ 0 = 1
x ^ 1 = x
x ^ (2*n+1) = x*xn*xn where xn = x^n
x ^ (2*n) = xn*xn where xn = x^n
x ^^ (-n) = 1/(x^n)
x ^^ n = x^n
/kent k