|
|
|
|
|
by hansvm
647 days ago
|
|
Sometimes mutations in comprehensions are very expressive. def scan(items, f, initial):
x = initial
return (x := f(x, y) for y in items)
There are lots of other short ways to write `scan`, but I don't think any of them map so clearly to a naive definition of what it's supposed to do. |
|