-
-
Save kureikei/4d8af8fbd23c6547dbb9 to your computer and use it in GitHub Desktop.
This file contains 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
// コマンドライン引数に俳句を半角スペースで5・7・5に区切って入力してから、実行します。 | |
[<EntryPoint>] | |
let main argv = | |
// 文字数1番多い行の文字数を求めます。 | |
let max = ( argv |> Seq.maxBy( fun a -> a.Length ) ).Length | |
// 各行は上で求めた文字数になるように、全角スペースで末尾をパディングします。 | |
let argv2 = argv |> Array.map( fun a -> a.PadRight( max, ' ' ) ) | |
// 文字列のを縦書きになるように並び替えて、出力します。 | |
Array.init max ( fun i -> System.String( [| for j in 0..argv2.Length - 1 -> argv2.[j].[i] |] |> Array.rev ) ) | |
|> Array.iter( fun v -> v |> printfn "%s" ) | |
0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment