Created
May 9, 2016 02:15
-
-
Save yas375/585fb4366cddfa0fbd2c612f00ccf62b 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 | |
} | |
let xs = [1, 4] | |
let bs = Array(xs.lazy | |
.map(double) | |
.map(triple) | |
) | |
print("result: \(bs)") |
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 | |
double 4 | |
triple 8 | |
result: [6, 24] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I've got the expected behavior with
filter
in https://gist.github.com/yas375/e63416596701e6cece2e2158cc0b8c1d