assgnment2 higher-order functions