9/34
Part 3 of 8 · BatchesLearn and do

A bad step list is one mistake, so it raises once, before the loop

The first line of run_batch, check(steps), sits outside the loop on purpose. A bad step list is one mistake, made once, by whoever wrote the steps. It should raise once, before anything runs.

Leave that line out and apply still checks, but now inside the try, so the step list's ValueError is caught per table. Two tables with [("sort", -1)] came back as [ValueError("bad step: ('sort', -1)"), ValueError("bad step: ('sort', -1)")]. The caller sees what looks like two bad tables, and one mistake is reported once per table.

apply checking again inside the loop is harmless: O(s) per table, next to work that touches every value.

Cost. O(n r c s) time for n tables of r by c, through s steps that touch every value. Memory holds all n results, which the caller asked for.

In the editor, write run_batch(tables, steps) yourself. check and apply are the ones from the lesson. A bad table fills its own slot, and a bad step list raises before any table runs.