from goody import irange from generator import sequence, transform, count, chunk_sum, flatten for i in sequence('abcd','ef','ghij'): print(i,end='') print() def upper(x): return x.upper() for i in transform('abCdeFg',upper): print(i,end='') print() def is_upper(x): return x == x.upper() for i in count('aBcDEfGhijK',is_upper): print(i,end=' ') print() for i in chunk_sum(irange(1,20),5): print(i,end=' ') for i in flatten([1,2,[3,4,(5,6,7,{'abc':1,'xyz':2}),8,9],10]): print(i,end=' ')
from goody import irange from generator import sequence, transform, count, chunk_sum, flatten for i in sequence('abcd', 'ef', 'ghij'): print(i, end='') print() def upper(x): return x.upper() for i in transform('abCdeFg', upper): print(i, end='') print() def is_upper(x): return x == x.upper() for i in count('aBcDEfGhijK', is_upper): print(i, end=' ') print() for i in chunk_sum(irange(1, 20), 5): print(i, end=' ') for i in flatten([1, 2, [3, 4, (5, 6, 7, {'abc': 1, 'xyz': 2}), 8, 9], 10]): print(i, end=' ')
from generator import lets, transform, running_count, n_with_pad, sequence, alternate for i in transform('abCdeFg',str.upper): print(i,end=' ') print() for i in transform(lets('abCdeFg'),str.upper): print(i,end=' ') print() for i in running_count('bananastand',lambda x : x in 'aeiou'): # is vowel print(i,end=' ') print() for i in running_count(lets('bananastand'),lambda x : x in 'aeiou'): # is vowel print(i,end=' ') print() for i in n_with_pad('abcdefg',3,None): print(i,end=' ') print() for i in n_with_pad('abcdefg',10,'?'): print(i,end=' ') print() for i in n_with_pad('abcdefg',10):
from goody import irange from generator import sequence, transform, count, chunk_sum for i in sequence('abcd','ef','ghij'): print(i,end='') print() def upper(x): return x.upper() for i in transform('abCdeFg',str.upper): print(i,end='') print() for i in count('aBcDEfGhijK',lambda x : 'A'<=x<='Z'): # is upper-case print(i,end=' ') print() for i in chunk_sum(irange(1,20),5): print(i,end=' ') for i in flatten([1,2,[3,4,(5,6,7,{'abc':1,'xyz':2}),8,9],10]): print(i,end=' ')
# A generator for iterating through any iterable (mostly used to # iterate through the letters in a string). # It is present and called to ensure that your generator code works on # general iterable parameters (not just a string, list, etc.) # For example, although we can call len(string) we cannot call # len(lets(string)), so the generator functions you write should not # call len on their parameters def lets(iterable): for i in iterable: yield i for i in transform("abCdeFg", str.upper): print(i, end=" ") print() for i in transform(lets("abCdeFg"), str.upper): print(i, end=" ") print() for i in running_count("bananastand", lambda x: x in "aeiou"): # is vowel print(i, end=" ") print() for i in running_count(lets("bananastand"), lambda x: x in "aeiou"): # is vowel print(i, end=" ") print()
from generator import lets, transform, running_count, n_with_pad, sequence, alternate for i in transform('abCdeFg', str.upper): print(i, end=' ') print() for i in transform(lets('abCdeFg'), str.upper): print(i, end=' ') print() for i in running_count('bananastand', lambda x: x in 'aeiou'): # is vowel print(i, end=' ') print() for i in running_count(lets('bananastand'), lambda x: x in 'aeiou'): # is vowel print(i, end=' ') print() for i in n_with_pad('abcdefg', 3, None): print(i, end=' ') print() for i in n_with_pad('abcdefg', 10, '?'): print(i, end=' ') print() for i in n_with_pad('abcdefg', 10): print(i, end=' ') print()