Skip to content

Instantly share code, notes, and snippets.

@oinopion
Created December 15, 2011 13:18
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 oinopion/1481061 to your computer and use it in GitHub Desktop.
Save oinopion/1481061 to your computer and use it in GitHub Desktop.
# encoding: utf-8
def fib_gen():
a, b = 1, 1
while True:
yield a
a, b = b, a+b
def get_values(iterator, n):
l = []
for i in range(n):
l.append(iterator.next())
return l
# z wyrażeniem generatorowym
def get_values_comprehension(iterator, n):
return [next(iterator) for i in range(i)]
def sequence_get(next_generator, *args):
args = list(args)
n = 0
while True:
yield args[n]
value = next_generator(*args)
args = args[1:] + [value]
# elo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment