replace Array.iteri and List.iteri with 3.12-friendly versions