Skip to content

Instantly share code, notes, and snippets.

@kureikei
Created March 1, 2015 21:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kureikei/4d8af8fbd23c6547dbb9 to your computer and use it in GitHub Desktop.
Save kureikei/4d8af8fbd23c6547dbb9 to your computer and use it in GitHub Desktop.
// コマンドライン引数に俳句を半角スペースで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