matrix.hs -- rework nan_row to use foldl. generalize findFirstNZ.