Population count: Difference between revisions

Content added Content deleted
m (→‎{{header|Haskell}}: Tidied, applied Ormolu.)
m (→‎{{header|Haskell}}: Legibility)
Line 2,038: Line 2,038:
popCount = sum . unfoldr go
popCount = sum . unfoldr go
where
where
go =
go x
| 0 < x = (Just . swap) (quotRem x 2)
( bool Nothing
. Just
| otherwise = Nothing
. swap
. flip quotRem 2
)
<*> (0 <)


--------------------------- TEST -------------------------
--------------------------- TEST -------------------------