Generic operations on an array of arrays, that I kept re-implementing in several projects