Last active
November 8, 2016 07:21
-
-
Save callmekohei/ffc685e9e7bce566da7086586c68e110 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let inline prettyPrint (row : int ) (space : string) (lst: 'a list) = | |
let swapRowColumn lst = | |
lst | |
|> List.collect List.indexed | |
|> List.groupBy fst | |
|> List.map snd | |
|> List.map (List.map snd) | |
let sjis = System.Text.Encoding.GetEncoding "Shift_JIS" | |
let justify lst = | |
let lst = lst|> List.map ( fun x -> string x , sjis.GetByteCount (string x) ) | |
let max = | |
lst | |
|> List.map snd | |
|> List.max | |
List.map (fun (str, len) -> str + String.replicate (max - len) " ") lst | |
lst | |
|> List.chunkBySize row | |
|> swapRowColumn | |
|> List.map justify | |
|> List.map ( List.reduce ( fun a b -> a + space + b )) | |
|> List.iter ( fun l -> printfn "%s" l ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
.