ぶっちゃけ始めるのにいい言語て何 part6at TECH
ぶっちゃけ始めるのにいい言語て何 part6 - 暇つぶし2ch357:デフォルトの名無しさん
21/08/23 22:15:20.58 x2dcVOdp.net
>>295 ocaml
URLリンク(ideone.com)
let f1 x = String.concat "-" (List.map string_of_int (List.rev (List.sort compare x)))
(* @@ Application operator *)
let f2 x = String.concat "-" @@ List.map string_of_int @@ List.rev @@ List.sort compare x
(* |> Reverse-application operator *)
let f3 x = List.sort compare x |> List.rev |> List.map string_of_int |> String.concat "-"
let (<<) f g x = f (g x)
let f4 = String.concat "-" << List.map string_of_int << List.rev << List.sort compare
let (>>) f g x = g (f x)
let f5 = List.sort compare >> List.rev >> List.map string_of_int >> String.concat "-"
let () = List.iter (fun f -> print_endline @@ f [1;1;9;2]) [f1;f2;f3;f4;f5]

9-2-1-1
9-2-1-1
9-2-1-1
9-2-1-1
9-2-1-1


次ページ
続きを表示
1を表示
最新レス表示
レスジャンプ
類似スレ一覧
スレッドの検索
話題のニュース
おまかせリスト
オプション
しおりを挟む
スレッドに書込
スレッドの一覧
暇つぶし2ch