Re: [q-lang-users] Exponentiation operator
Brought to you by:
agraef
From: Albert G. <Dr....@t-...> - 2006-06-16 21:04:36
|
Rob Hubbard wrote: > All the functions return a "normalised" value. Thus a simple way to > implement the other behaviour is to change "normalisation" to reduce to > Int when possible. You will find that those cases are already treated separately (for optimization purposes) in the prototype stdlib rational.q that I sent you in private mail. So the necessary changes are in fact trivial. > There's a chance that some of my algorithms will need > to be tweaked afterwards, as sometimes I assume in some private > functions that a value is in the form (rat N D). Those parts of your module will end up in the separate ratutils.q module and thus need to be rewritten anyway, because ratutils won't have access to the rat constructor any more (which is private to rational.q). I've already checked this, the necessary changes should be rather minimal. BTW, even if we don't decide for the "auto-simplification", I'd like to propose that the numerator, denominator and num_den functions should accept Int arguments, too, then _all_ operations in the rational base module would work on Rational and Int alike. This would also be analogous to complex.q, where 're' and 'im' are also defined on Real. > I think that the behaviour ought to follow the style of what you do with > (^). Ok, so that would mean that we never promote the result to a type less general that the argument types. Fair enough. That's what effectively happens in Haskell, too, AFAICS. John, you argued in favour of "auto-simplification", do you think you can also live without it? Albert -- Dr. Albert Gr"af Dept. of Music-Informatics, University of Mainz, Germany Email: Dr....@t-..., ag...@mu... WWW: http://www.musikinformatik.uni-mainz.de/ag |