pschwarz (8) [Avatar] Offline

in the following section of listing 2.3, do 'a' and 'e' stand for accumulator and element?

List(s1, s2, s3).map(calculateInterest(_, dateRange))
.foldLeft(BigDecimal(0)((a, e) => + a).getOrElse(a)) #C

If, so, is there a strong enough argument for calling them so, or calling them 'acc' and 'el'?


Debasish Ghosh (116) [Avatar] Offline
Exactly .. that's a convention I follow .. a for accumulator & e for element. But I agree a bit more verbose that u suggest is always better to some. However keeping in mind the space that I can afford in the book code snippets, I have stuck to a and e. It may not be that long in this snippet, but it often becomes difficult to fit the snippet without folding.