Reimplement sum/product/length using foldLeft.