On 12/16/2013 12:38 PM, Andrei Alexandrescu wrote:
bool between(T, U1, U2)(T v, U1 lo, U2 hi)
{
return v >= lo && v <= hi;
}
You'd need 4 such functions, < <, < <=, <= <, <= <=, and it just seems like trivia.
uint among(T, Us...)(T v, Us vals)
{
foreach (i, U; Us)
{
if (v == vals[i]) return i + 1;
}
return 0;
}
This has O(n) behavior, which might be unexpected for the user.
