An experiment with functional programming in Swift