This is a tangent, but I've been thinking about how I feel when the conditions of an if-else ladder rely on the order they're listed in.
This is an example; if you swapped the order of those branches around, the coloration would become incorrect.
I'm a little happier when the conditions are described completely, such that swapping the order of the checks doesn't change which of them evaluate false or true, but it's also true that that can add quite a bit of complexity over an order-sensitive set of conditions.
Thoughts?
(first (filter identity
[(and (condition-three) (action-three))
(and (condition-one) (action-one))
(and (condition-four) (action-four))
(and (condition-two) (action-two))]))
And you could write a macro to do it with nice syntax. A bit more work and you could parallelize it.You probably wouldn't want to most of the time, but if the conditions are slow to test but otherwise inexpensive, it might be a useful optimization.