Skip to content

Instantly share code, notes, and snippets.

@oisdk
Created June 10, 2015 11:37
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 oisdk/ebeb2bf1affd80d193fb to your computer and use it in GitHub Desktop.
Save oisdk/ebeb2bf1affd80d193fb to your computer and use it in GitHub Desktop.
func forCStyle<T>(var start: T, _ condition: T -> Bool, _ increment: T -> T) -> AnyGenerator<T> {
return anyGenerator {
defer { start = increment(start) }
return condition(start) ? start : nil
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment