Andrei Alexandrescu wrote:
Jérôme M. Berger wrote:- A floating point range should allow you to specify the iteration step, or else it should allow you to iterate through all numbers that can be represented with the corresponding precision;We don't have that, so you'd need to use a straigh for statement.
struct FloatRange {
float begin, end, step;
bool includeBegin, includeEnd;
int opApply (int delegate (ref float) dg) {
whatever;
}
whatever;
}
So would I. But a range of floats is useful for more than iterating over it. Think interval arithmetic for example.- The second issue remains: what if I want to include b but not b+ε for any ε>0?real a, b; ... for (real f = a; f <= b; update(f)) { } I'd find it questionable to use ranged for with floats anyway.
Jerome
--
mailto:[email protected]
http://jeberger.free.fr
Jabber: [email protected]
signature.asc
Description: OpenPGP digital signature
