Skip to content

Instantly share code, notes, and snippets.

@yas375
Created May 9, 2016 02:15
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/585fb4366cddfa0fbd2c612f00ccf62b to your computer and use it in GitHub Desktop.
Save yas375/585fb4366cddfa0fbd2c612f00ccf62b 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
}
let xs = [1, 4]
let bs = Array(xs.lazy
.map(double)
.map(triple)
)
print("result: \(bs)")
double 1
triple 2
double 4
triple 8
result: [6, 24]
@yas375
Copy link
Author

yas375 commented May 9, 2016

I've got the expected behavior with filter in https://gist.github.com/yas375/e63416596701e6cece2e2158cc0b8c1d

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment