News for hackers. Stuff that matters.
Re:Ask HN: What is your go to idiot-filter question in inter... by pklausler on Wednesday December 07, 2022 @05:20PM (#33901162)
mean = liftA2 (/) sum length
Re:Ask HN: What is your go to idiot-filter question in inter... by Kranar on Wednesday December 07, 2022 @05:34PM (#33901318)
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.
Re:Ask HN: What is your go to idiot-filter question in inter... by whatshisface on Wednesday December 07, 2022 @05:44PM (#33901440)
That could turn in to a very complex question in that case because dividing too many separate sums before adding would introduce rounding error.
Re:Ask HN: What is your go to idiot-filter question in inter... by anyfoo on Wednesday December 07, 2022 @06:09PM (#33901722)
Does that not have to be

    mean = liftA2 (/) sum (fromIntegral . length)

?