5 ms·
squares = [x * x for x in range(10)] print(min(squares)) print(max(squares)) this one works and looks good.
by c8g 8y ago
squares = [x * x for x in range(10)]
print(min(squares))
print(max(squares))
this one works and looks good.
- skbly7 8y agoIt will have memory impact though with larger range. A better approach might be: squares = lambda: (x * x for x in range(10)) print(min(squares)) print(max(squares()))
- rahimnathwani 8y agoYes, your solution is in the original post, under the heading 'Python solutions': def squares(): return (x * x for x in range(10))
- adrianN 8y agoIt also uses O(n) memory.
- sitkack 8y agoWe need a language that can schedule and fuse those folds over an infinite sequence concurrently. Joining a set of futures over an infinite sequence fuses folds
- deleted 8y ago[deleted]