how to make the function "length" from "map" and "sum"