2014-04-18 02:34:25 +04:00
|
|
|
#!/usr/bin/env runhaskell
|
|
|
|
|
|
|
|
-- |
|
2018-03-22 23:33:12 +03:00
|
|
|
-- Module : Main
|
2016-01-19 22:31:37 +03:00
|
|
|
-- Copyright : (c) 2013-2016 Galois, Inc.
|
2014-04-18 02:34:25 +04:00
|
|
|
-- License : BSD3
|
|
|
|
-- Maintainer : cryptol@galois.com
|
|
|
|
-- Stability : provisional
|
|
|
|
-- Portability : portable
|
|
|
|
|
|
|
|
{- A utility for spliting a long column of stuff into multiple columns. -}
|
2022-06-14 01:56:15 +03:00
|
|
|
import Data.List(transpose,sort)
|
2014-04-18 02:34:25 +04:00
|
|
|
|
|
|
|
rs = 4 -- number of rows per column
|
|
|
|
spacing = 4 -- blanks between columns
|
|
|
|
|
2022-06-14 01:56:15 +03:00
|
|
|
main = interact (unlines . map concat . transpose . map toCol . chop rs . sort . lines)
|
2014-04-18 02:34:25 +04:00
|
|
|
|
|
|
|
colWidth xs = spacing + maximum (0 : map length xs)
|
|
|
|
|
|
|
|
padTo x xs = xs ++ replicate (x - length xs) ' '
|
|
|
|
|
|
|
|
toCol xs = map (padTo (colWidth xs)) xs
|
|
|
|
|
|
|
|
chop n [] = []
|
|
|
|
chop n xs = let (as,bs) = splitAt n xs
|
|
|
|
in as : chop n bs
|