From: Albert G. <Dr....@t-...> - 2008-07-08 12:18:28
|
Libor Spacek wrote: > I was not really thinking about rationals and complex numbers and anything else yet. Yes, but at least the rationals have to work, too. > Here are my defs for ndiv and slash (new /). In practice, you could of course just add > these extra cases to the existing definitions without using new symbols: This will have to be so, since I don't want to have more division operators in the library, unless there's a *really* compelling reason for them. > infixl 7 slash; > x::int slash y::int = x div y if x mod y==0; > x slash y = x/y; A division operator which returns ints only if x divides y? I don't think that this is a good idea, as you never know which type is returned. The rationale behind / is precisely that you *always* get a double result, same with '^'. That's the Algol philosophy and I think it's good; I won't change it. div/mod is another business; as long as they work consistently with the integer div/mod and they cover all appropriate cases including rationals I'm willing to add the extensions. 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 |