Follow Expression Traversals
Echo and EchoFunction allow reporting the order in which elements of expressions are sequentially visited during pattern matching.
Observe the order in which Cases visits parts of the first level of an expression.
In[1]:=
Cases[{a, 2, {7, {1, b}}, 0}, x_ /; NumberQ[Echo[x]]]
»
»
»
»
Out[1]=
Visit all levels of the same expression.
In[2]:=
Cases[{a, 2, {7, {1, b}}, 0}, x_ /; NumberQ[Echo[x]], All]
»
»
»
»
»
»
»
»
»
Out[2]=