Although I have used Mathematica for a while I still consider myself a noobie. I still don’t understand the fundamental concepts of many of the functions. My question in this case is why I need the Evaluate function to make the following example code work?
This means that it will not evaluate eventlist and “eventlist” unevaluated does not have any conditions that trigger an event. You can only trigger an event if you evaluate eventlist to obtain the equality conditions.
What HoldAll actually means is that the arguments will not be evaluated before being passed to WhenEvent. The function itself is free to do anything it wants with them, including evaluation.
Evaluate is needed here since you are building the list of events programmatically. Without it, when passed in, it’s just an expression with head Map (not an explicit List which tells WhenEvent to set up multiple events) and given numeric values it would never evaluate to False or True, so no events will be detected.