Re:The Wrong Aesthetic
by lsb on Sunday June 13, 2010 @01:27PM
(#1427758)
And in Haskell,
would use fusion to avoid causing map to create another array!
[ Parent
| on HN ]
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)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`.