Lukas Renggli wrote:
Summing up the numbers from 1 to 100 can be done as easily as:
(1 to: 100) fold: [ :a :b | a + b ].
This is similar to what's called "reduce" in the functional-programming world; a true fold needs to take a seed as well,
(1 to: 100) fold: 0 by: [:a :b| a + b]. (1 to: 100) fold: [:a :b| a + b] with: 0.
for instance. Then of course you get the left-fold/right-fold distinction, and quickly veer off into category theory from whence none have returned.
Tony