Skip to content

Instantly share code, notes, and snippets.

@mratsim
Created July 4, 2017 19:49
Show Gist options
  • Save mratsim/e0c7f2eefb8fa91fb27f0cd9a97cff00 to your computer and use it in GitHub Desktop.
Save mratsim/e0c7f2eefb8fa91fb27f0cd9a97cff00 to your computer and use it in GitHub Desktop.
Nim while let
proc filter[T](it: (iterator : T), f: proc(x: T): bool): (iterator: T) =
return iterator(): T =
while (let x = it(); not finished(it)):
if f(x):
yield x
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment