This topic(how-does-vardradic-if-else-if-work-with-list-inputs) inspire me: How can i make a variadic if then else ? (and how it can accept a list of conditions in the variadic arrows)
Thanks for sharing your code.
It works fine in most cases.
Just one remark ...
I slightly modified one of your test scripts:
with:
Now as it turns out, even if the first condition is met, the second condition is apparently evaluated in the process, as indicated by five seconds of wait time. I don't suppose this is what you have been looking for..
Hint: evaluate the first condition first, then (depending on the result) either execute the first action, or use recursion to proceed with the second (and following) cases (don't forget to include a base case at the very start of the recursive function: if the list of conditions is empty, execute the default action and stop).
In this block version, i've try to avoid the for each block.
If I'm for using the "for each" block, maybe I'll implement the new version like in C language: with an optional break at the end of the conditional code
switch (age) {
case 1: printf("You're one."); break;
case 2: printf("You're two."); break;
case 3: printf("You're three.");
case 4: printf("You're three or four."); break;
default: printf("You're not 1, 2, 3 or 4!");
}