High order functions in Swift