Skip to content

Instantly share code, notes, and snippets.

@yas375
Last active May 9, 2016 02:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yas375/e63416596701e6cece2e2158cc0b8c1d to your computer and use it in GitHub Desktop.
Save yas375/e63416596701e6cece2e2158cc0b8c1d to your computer and use it in GitHub Desktop.
func double(value: Int) -> Int {
print("double \(value)")
return value * 2
}
func triple(value: Int) -> Int {
print("triple \(value)")
return value * 3
}
func filter(value: Int) -> Bool {
print("filter \(value)")
return value < 10
}
let bs = [1, 4].lazy
.map(double)
.map(triple)
.filter(filter)
print(Array(bs.generate()))
double 1
triple 2
filter 6
double 4
triple 8
filter 24
[6]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment