Re: [q-lang-users] Exponentiation operator
Brought to you by:
agraef
From: John C. <co...@cc...> - 2006-06-16 19:23:18
|
Albert Graef scripsit: > Now I'm reconsidering this. Maybe it would be better if ^ actually > returned an Int where this is possible, and a Float otherwise? (This > wouldn't be possible in a language with static typing like Haskell, of > course, but Q doesn't have this problem.) A similar issue arises with > the definition of ^ for Rational. Should Rational ^ Int be a Rational? > Or a Float, like Rational ^ Rational and Rational ^ Float are? I'd split ^ into two operators, one to return a Float (perhaps ^) always, and one to return an exact result where possible, a Float where necessary (perhaps **, perhaps pow). > A related question is whether rational arithmetic should return an Int > instead of a Rational when the denominator of the result is 1. I think it should, yes. And likewise when the numerator is 0. I also think, for the same reasons, that a complex operator should return a Real when the imaginary part is 0 (but not 0.0), for reasons stated before. -- Knowledge studies others / Wisdom is self-known; John Cowan Muscle masters brothers / Self-mastery is bone; co...@cc... Content need never borrow / Ambition wanders blind; http://ccil.org/~cowan Vitality cleaves to the marrow / Leaving death behind. --Tao 33 (Bynner) |