an approach to coding higher-order functions