Re:SICP Goodness – Why you don't need looping constructs
by goalieca on Friday June 29, 2018 @03:34PM
(#17427131)
But foreach is a function.
The weird thing about your pattern is that class.a() and class.b() may have side effects and don’t seem to depend on i at all. If I were to optimize this loop or even make it parallel, then I’m certainly missing some information. Some information that could be captured by another expression.
foreach(i in list){
if i == 0 { class.a() }
else { class.b() }
}