Defining higher-order functions reduce, map, and filter recursively