Skip to content
Advertisement

List iteration with substitution into one-liner

I want to turn the following for loop:

JavaScript

into a one liner. I figured I could do something like this:

JavaScript

but I need to update the value of x0 in each instance of the loop. Any ideas?

Advertisement

Answer

Walrus operator := to the rescue:

JavaScript
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement