Patternmatching and higher order functions