Fix foldl function for nested arrays.