Y
Hacker News
new
|
ask
|
show
|
jobs
by
pklausler
1289 days ago
mean = liftA2 (/) sum length
2 comments
Kranar
1289 days ago
I mean that could satisfy the interviewer, but for me if I asked that question, I'd want an answer that protected against overflow and unfortunately the naive solution is prone to overflow.
link
whatshisface
1289 days ago
That could turn in to a very complex question in that case because dividing too many separate sums before adding would introduce rounding error.
link
anyfoo
1289 days ago
Does that not have to be
mean = liftA2 (/) sum (fromIntegral . length) ?
link