Taxicab numbers: Difference between revisions

Content added Content deleted
m (→‎{{header|Haskell}}: Pruned out one import.)
(→‎{{header|Haskell}}: Data.Function (on) for simpler groupBy expression)
Line 1,220: Line 1,220:


<lang haskell>import Data.List (groupBy, sortOn, tails, transpose)
<lang haskell>import Data.List (groupBy, sortOn, tails, transpose)
import Data.Function (on)


--------------------- TAXICAB NUMBERS --------------------
--------------------- TAXICAB NUMBERS --------------------
Line 1,226: Line 1,227:
taxis nCubes =
taxis nCubes =
filter ((> 1) . length) $
filter ((> 1) . length) $
groupBy ((. fst) . (==) . fst) $
groupBy (on (==) fst) $
sortOn fst
sortOn fst
[ (fst x + fst y, (x, y))
[ (fst x + fst y, (x, y))