Skip to content

Instantly share code, notes, and snippets.

@ilyapuchka
Last active August 29, 2015 14:25
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 ilyapuchka/fcb4c50ca5fb49ecc072 to your computer and use it in GitHub Desktop.
Save ilyapuchka/fcb4c50ca5fb49ecc072 to your computer and use it in GitHub Desktop.
Guess what it does
func z_map<S : SequenceType, T>(source: S, transform: (S.Generator.Element) -> T?) -> [T] {
// easy, right? =)
return reduce(source, []) { r, i in map( transform(i) ) { r + [$0] } ?? r }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment