Variadic if-else?


Easy to do…is it a good idea?

The C++ code is identical to existing if-else.
The down-side is the order of pins needs to be kind of funky to work with variadic-2.

It will return the T of the right-most true COND, or F if none are true.



Oh! Interesting use case. It’s a kind of nested ternary in conventional programming language:

const howMany =
  (x > 2000) ? "thousands" :
  (x > 200) ? "hundreds" :
  (x > 24) ? "dozens" :

Would be nice if you publish a library with it, so that one can feel how convenient it is.

There’s still a TODO-feature with variadics: something like a variadic-bypass marker which would allow composing a new variadic node out of existing variadics and rearrange or hide terminal as desired. It should make possible creating, e.g., average node or your proposal with the “right” pin order.


gweimer/utils now includes if-else-v & if-else-v-string (variadic version of original)