The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

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.