renamed foldLeft to reduce