How to slice your code into continuations
The difference between for b in C and is merely syntactic and Python could probably have been designed to use a syntax like
This suggests the possibility that if we enabled the overloading of in the right way, it would allow us to implement list comprehension in a language that doesn’t have explicit list comprehension support. You might guess that the way we might use it is to overload above with Python’s function that applies a function to every element of a list and collects the results in a list. For example, in probability theory we often see notation like
Like with assignments and list comprehension we have pairs of variable names and expressions.
Source: dpiponi.github.io