3 ms·
In actual Haskell I would write it as sum [ n^2 | n <- [1..5], n % 3 == 1 ] which seems to express the idea fairly directly and I'm fairly sure has a clos
by lgas 7y ago
In actual Haskell I would write it as
sum [ n^2 | n <- [1..5], n % 3 == 1 ]
which seems to express the idea fairly directly and I'm fairly sure has a close analog in python.
- lightsighter 7y agopython: sum([n * n for n in range(1,5,3)])
- marai2 7y agohaskell: sum [n^2 | n <- [1,3..5]] I just remembered haskell's "range" operator ".." can also take a step size. ['a', 'd' .. 'z'] => "adgjmpsvy"