3 ms·
Yes, staying idiomatic is a good idea, it's worth pointing out explicitly. As a tangent, while the original author was trying to abstract away the loop, I feel
by DougBTX 16y ago
Yes, staying idiomatic is a good idea, it's worth pointing out explicitly.
As a tangent, while the original author was trying to abstract away the loop, I feel he left too many fragments of the loop behind, such as the start and end conditions. As such, I don't think the sum function is cheating too much, and is in fact the goal. I might describe the Total as "the sum of the dies' face values," instead of the more verbose: "the sum of the dies' face values, starting from the first die and ending at the last die."
In a sense, this runs parallel to your reminder to stay idiomatic: when you sum a list of things, it is common to add them all together, not just some subset. It is this shared understanding which lets us be succinct.
Though I do fear that I'm preaching to the choir :-)