On 2013-12-16 20:38:51 +0000, Andrei Alexandrescu said:
bool between(T, U1, U2)(T v, U1 lo, U2 hi) { return v >= lo && v <= hi; } uint among(T, Us...)(T v, Us vals) { foreach (i, U; Us) { if (v == vals[i]) return i + 1; } return 0; } Add? Andrei
as Walter mentioned, between should have different versions. Aslo might be useful to have a generalized Range type (not to be confused with iteration ranges). Having used Guava range [1] type, I can say it was very useful (especially implementing a predicate interface, enabling filtering with a range)
1. https://code.google.com/p/guava-libraries/wiki/RangesExplained