Skip to content

Instantly share code, notes, and snippets.

@motokiee
Last active August 29, 2015 14:22
Show Gist options
  • Save motokiee/7d1111d2dd5522d16f47 to your computer and use it in GitHub Desktop.
Save motokiee/7d1111d2dd5522d16f47 to your computer and use it in GitHub Desktop.
let numbers = [0,1,2,3,4,5]
var sum = { (a:Int, b:Int) -> Int in
a + b
}
var odd = { (number:Int) -> Bool in
number % 2 != 0
}
var multiply = { (number:Int) -> Int in
number * 2
}
numbers.reduce(0, combine: sum)
numbers.filter(odd)
numbers.map(multiply)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment