implement reduce
reduce, map, and filter