Skip to content

Instantly share code, notes, and snippets.

@gokr
Created May 20, 2015 11:10
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 gokr/a14df619dca672cdea8b to your computer and use it in GitHub Desktop.
Save gokr/a14df619dca672cdea8b to your computer and use it in GitHub Desktop.
twopow
var a = [1,2,3,4,5,6]
iterator twopow[T](a: openarray[T]): T =
var i = 1
while i <= a.high:
yield a[i-1]
i = i * 2
for x in twopow(a): echo x
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment