Jump to content

Base-16 representation: Difference between revisions

m
(→‎{{header|JavaScript}}: Added a JavaScript version.)
Line 875:
<> show upperLimit
<> ":\n",
table justifyRight " " $ chunksOf 15 xs
]
 
------------------------- DISPLAY ------------------------
 
table :: String -> [[String]] -> String
(Int -> Char -> String -> String) ->
table gap rows =
String ->
let ws = maximum . fmap length <$> transpose rows
[[String]] ->
pw = printf . flip intercalate ["%", "s"] . show
String
in unlines $ intercalate gap . zipWith pw ws <$> rows</lang>
table alignment gap rows =
unlines $
fmap
( intercalate gap
. zipWith (`alignment` ' ') colWidths
)
rows
where
let ws colWidths = maximum . fmap length <$> transpose rows
 
justifyRight :: Int -> Char -> String -> String
justifyRight n c = (drop . length) <*> (replicate n c <>)</lang>
{{Out}}
<pre>301 matches up to 500:
9,659

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.