Align columns: Difference between revisions
m
→{{header|Haskell}}: (Minor linting and import pruning of existing example)
m (→{{header|Haskell}}: (Minor linting and import pruning of existing example)) |
|||
Line 2,461:
=={{header|Haskell}}==
<lang haskell>import Data.List (unfoldr, transpose)
import Control.
dat =
"are$delineated$by$a$single$'dollar'$character,$write$a$program\n" ++
"justified,$right$justified,$or$center$justified$within$its$column.\n"
brkdwn =
format j ls = map (unwords . zipWith align colw) rows
where
rows = map brkdwn $ lines ls
colw = map (maximum . map length) . transpose $ rows
align cw w =
case j of
'c' ->
'r' ->
'l' -> w ++
{{out}}
<pre>
|