On 12/17/13, 4:38, Andrei Alexandrescu wrote:
bool between(T, U1, U2)(T v, U1 lo, U2 hi)
{
return v >= lo && v <= hi;
}
The expression a<b<c is not ambiguous in D. We could make it do what
people expect.
uint among(T, Us...)(T v, Us vals)
{
foreach (i, U; Us)
{
if (v == vals[i]) return i + 1;
}
return 0;
}
"in"?
assert("a" in ["a":1, "b":1]);
Again, with little compiler magic we could allow that to be written as
assert("a" in ["a", "b"]);
Note that I'm not advocating for O(n) "in" for regular arrays, but
merely for the compiler to recognize the "in []" pattern and Do The
Right Thing.
L.