Provide arbitrary length if-elif-else constructs
if-elif-else constructs are fine from a functional POV but currently are only possible with the switch
op. It would be nice to extend this to an arbitrary number of else if
's as this currently requires nesting switch
ops, which is not very convenient.
C++14 makes it quite easy:
auto f = [](auto a, auto va, auto b, auto vb, auto def) { if (a) return va; else if (b) return vb; else return def; };
so that
auto x = f(condA, valA, condB, valB, defVal);
is equivalent to:
if (condA) x = valA;
else if (condB) x = valB;
else x = defVal;
The C++ string could then be generated from a python helper called as:
ifElifElse((condA, valA), (condB, valB), defVal)
But I don't quite see how to implement this in the treeops/treeproxies...