DEV Community

Discussion on: Daily Challenge #225 - Square'n'Sum

Collapse
 
swizzard profile image
sam • Edited

Point free baby!

import Data.Monoid (Sum(..))

squareSum :: (Num c, Foldable t) => t c -> c
squareSum = getSum . foldMap (Sum . (^2))

(Obviously this is probably too polymorphic, you could just limit it to [Int] -> Int)