Skip to content

Instantly share code, notes, and snippets.

@russbishop
Created August 10, 2015 22:39
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 russbishop/a574a53649c55b5c380f to your computer and use it in GitHub Desktop.
Save russbishop/a574a53649c55b5c380f to your computer and use it in GitHub Desktop.
var g = (0..<10).generate()
let seq = lazy(AnySequence(anyGenerator { _ -> Int? in
print("called") //prints "called" 11 times
return g.next()
}))
.filter { $0 != 2 }
.filter { $0 != 4 }
for x in seq {
print("item: \(x)")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment