Created
July 4, 2017 19:49
-
-
Save mratsim/e0c7f2eefb8fa91fb27f0cd9a97cff00 to your computer and use it in GitHub Desktop.
Nim while let
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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