Trying to Monitor
a process using the postfix notation, as in
Table[Pause[n/10], {n, 5}] // Monitor[#, n] &
fails: the argument Table[Pause[n/10], {n, 5}]
is evaluated before being passed to the pure function Monitor[#,n]&
because that function does not have the attribute HoldAll
like Monitor
itself.
An option is to Hold
explicitly and release the hold inside the pure function:
Table[Pause[n/10], {n, 5}] // Hold // Monitor[ReleaseHold[#], n] &
Is there a simpler/cleaner/shorter way? Obviously Monitor[Table[...],n]
works, but I'd rather separate the code from the monitoring.
Table[...] ~Monitor~ n
. $\endgroup$