Quick actions

cmd+k|ctrl+k

Navigation

Languages

cs320-hw2-Python Generator Demo

Snippet info

Language

Python

Visibility

public

Author

o1xhack

Created

2016-10-03T21:05:28Z

Updated

2016-10-03T21:16:11Z



def f(n): 
    x = n
    while True:
        yield x
        x = x+1
    
def take(xs, n):
    if n == 0:
        return []
    else:
        return [next(xs)] + take(xs, n-1)
    
print(take(f(2), 10))
INFO