2 ms·
List comprehension in Haskell is probably the best approach so far, imho. However once you're using these tools then map, reduce, filter should be easy to under
by proc0 7y ago
List comprehension in Haskell is probably the best approach so far, imho. However once you're using these tools then map, reduce, filter should be easy to understand, so the terseness and clarity of it doesn't come without a cost.
let mod3 n =
if n `mod` 3 == 1
then n
else 0
sum [ i^2 | i <- [ mod3 n | n <- [1..5] ] ]