Last active
May 9, 2016 02:51
-
-
Save yas375/e63416596701e6cece2e2158cc0b8c1d to your computer and use it in GitHub Desktop.
In continuation of https://gist.github.com/yas375/69d8643ff7d98b137cc2f8201c3e58fc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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())) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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