Using closures with Swift's array algorithms