File tree Expand file tree Collapse file tree 1 file changed +8
-5
lines changed
Expand file tree Collapse file tree 1 file changed +8
-5
lines changed Original file line number Diff line number Diff line change 11from .pipe import pipe
2- from itertools import product , islice
2+ from itertools import tee , islice
33
44INF = float ('inf' )
55NEGINF = float ('-inf' )
@@ -18,15 +18,18 @@ def __iter__(self):
1818 return self
1919
2020 def __mul__ (self , rhs ):
21- self .data = product (self , rhs )
22- return self
21+ def product (rhs ):
22+ for e1 in self :
23+ rhs , rhs_copy = tee (rhs )
24+ for e2 in rhs_copy :
25+ yield (e1 , e2 )
26+ return Iterator (product (rhs ))
2327
2428 def __next__ (self ):
2529 return next (self .data )
2630
2731 def slice (self , start = 0 , stop = None , step = 1 ):
28- self .data = islice (self .data , start , stop , step )
29- return self
32+ return Iterator (islice (self .data , start , stop , step ))
3033
3134class Range :
3235 def __init__ (self , start , end ):
You can’t perform that action at this time.
0 commit comments