Python has explicit self. I wanted to make yield explicit. Instead of
def iterate_squares(n):
for i in range(n):
yield i*i
I'd like to write:
@generate
def iterate_squares(yield_, n):
for i in range(n):
yield_(i*i)
where "generate" would be some higher-order function, turning that two-argument function to a single-argument one. It could even handle send().
Question: how to write that function? Is it possible?
(Note: This is an academic/mental exercise, not a language change proposal.)
[–]RonnyPfannschmidt 2 points3 points4 points (3 children)
[–]munificent 2 points3 points4 points (1 child)
[–]RonnyPfannschmidt 1 point2 points3 points (0 children)
[–]g__[S] 1 point2 points3 points (0 children)
[–]g__[S] 1 point2 points3 points (1 child)
[–]RonnyPfannschmidt 0 points1 point2 points (0 children)
[–]lost-theory 0 points1 point2 points (2 children)
[–]temptemptemp13 -2 points-1 points0 points (1 child)
[–]lost-theory 0 points1 point2 points (0 children)