News for hackers. Stuff that matters.
Re:The Wrong Aesthetic by loup-vaillant on Sunday June 13, 2010 @01:11PM (#1427727)
> I suspect those that have seen map, inject, and their ilk wouldn't be so confused.

No doubt. However, C++ stays a major contributor to that confusion. In ML languages,

    let total = foldl (+) 1 (map face_value dice)
is nearly idiomatic. Compare that to the C++ code. Compare that to C++ code that would use accumulate and an equivalent of map.
Re:The Wrong Aesthetic by iamwil on Sunday June 13, 2010 @02:52PM (#1427927)
I don't disagree. But it's a weakness of C++, not of the language concept itself.

Perhaps if OP was saying you shouldn't use it for C++, then maybe I'd say he'd have a case.

Re:The Wrong Aesthetic by jedbrown on Sunday June 13, 2010 @03:09PM (#1427956)
> Perhaps if OP was saying you shouldn't use it for C++

I think that's exactly what he was saying.

Re:The Wrong Aesthetic by loup-vaillant on Sunday June 13, 2010 @06:06PM (#1428299)
It is.
Re:The Wrong Aesthetic by iamwil on Sunday June 13, 2010 @07:42PM (#1428437)
Ah. I didn't get that from reading it.
Re:The Wrong Aesthetic by lsb on Sunday June 13, 2010 @01:27PM (#1427758)
And in Haskell,

  foldl (+) 1 (map face_value dice)
would use fusion to avoid causing map to create another array!
Re:The Wrong Aesthetic by nominolo on Sunday June 13, 2010 @01:55PM (#1427815)
Incidentally fusion won't work for this example (at least not as currently implemented.) Only `foldr` is fusable. Fortunately, regular inlining does just fine.

There is of course an even simpler version:

    sum (map face_value dice)
Re:The Wrong Aesthetic by ramchip on Sunday June 13, 2010 @02:12PM (#1427851)
Why does the sum start with 1? Why not eg.

     foldl1' (+) $ map face_value dice
Re:The Wrong Aesthetic by loup-vaillant on Sunday June 13, 2010 @06:10PM (#1428307)
It should have started with 0. Sorry. And I avoided `foldl1` because I wanted to stay close to C++'s `accumulate`.
Re:The Wrong Aesthetic by jvoorhis on Sunday June 13, 2010 @02:52PM (#1427926)
Shouldn't that be:

let total = foldl (+) 0 (map face_value dice)

Re:The Wrong Aesthetic by loup-vaillant on Sunday June 13, 2010 @06:08PM (#1428304)
Whoops. Yes it should.