static BufferedImage gridLOLToImage(L cellWidths, L cellHeights, LL lol) { L> lom = mapWithIndex(lol, (i, m) -> listToMatrix(cyclicGet(cellWidths, i), m)); MatrixOfMatrices mom = listToMatrix_cols(l(cellWidths), lom); L cellX1s = partialSums_firstIs0(cellWidths); L cellY1s = partialSums_firstIs0(cellHeights); int w = last(cellX1s), h = last(cellY1s); BufferedImage restored = newBufferedImage(w, h); forEachWithPosition(mom, (x, y, cell) -> drawIntMatrix(restored, cell, cyclicGet(cellX1s, x), cyclicGet(cellY1s, y))); ret restored; }