Refactor code that does not depend on y.
Essentially, the following logic:
Recall that some loops are folds, some are maps.
Maps look at only elements with one index. The important property of maps
is that map(f . g) = map(f) . map(g) - parts of the loop body can be split
into separate loops. Another property of maps is that if map(f) does not
depend on the output of map(g), then map(f) . map(g) = map(g) . map(f) -
the loops can be reordered.