4 ms·
Really? bind(std::plus(), _1, bind(&Die::faceValue, _2)) reads as "adding the face value of each die." to you? how. Because not knowing bind() or c++ I'm wond
by Avshalom 16y ago
Really?
bind(std::plus(), _1, bind(&Die::faceValue, _2))
reads as "adding the face value of each die." to you? how. Because not knowing bind() or c++ I'm wondering what _1 and _2 means. More importantly why bind seems to take an operator, _#, and something, on the outside but takes only an integer and _# on the inside call. and, although the surround code might explain it, where 'Die' came from.
Unless you're just overlooking everything on that line except Die::facevalue. If you are, then why keep mentioning the 'i' in the for loop version.
- sosorry 16y agoYes, really! I do a lot more functional programming than I do imperative programming. An anonymous function in context of an accumulator is obvious to me. The point that I maybe didn't make so well was that the second version is working in higher level constructs. The first version is doing a lot of integer and pointer manipulation, the second is summing across a collection. The two versions might be speaking in different languages, to some extent, but that doesn't mean that one or the other is aesthetically wrong.