Implement foldLeft.