Taxicab numbers: Difference between revisions
→{{header|Haskell}}: pp^2 (more legible pretty-printing code)
(→{{header|Haskell}}: pp^2 (more legible pretty-printing code)) |
|||
Line 1,195:
taxiRow :: (Int, [(Int, ((Int, Int), (Int, Int)))]) -> [String]
taxiRow (n, [(a, ((axc, axr), (ayc, ayr))), (b, ((bxc, bxr), (byc, byr)))]) =
concat
[
, term bxr bxc " + "
, term byr byc []
]
where
▲ ad = " + "
▲ or = " or "
-- OUTPUT -------------------------------------------------------------
Line 1,216 ⟶ 1,214:
let w = maximum (length <$> col)
in (justifyRight w ' ' <$> col)) <$>
transpose (taxiRow <$> (take 25 xs ++ take
where
justifyRight n c s = drop (length s) (replicate n c ++ s)</lang>
|