fork download
  1. let f1 x = String.concat "-" (List.map string_of_int (List.rev (List.sort compare x)))
  2.  
  3. (* @@ Application operator *)
  4. let f2 x = String.concat "-" @@ List.map string_of_int @@ List.rev @@ List.sort compare x
  5.  
  6. (* |> Reverse-application operator *)
  7. let f3 x = List.sort compare x |> List.rev |> List.map string_of_int |> String.concat "-"
  8.  
  9. let (<<) f g x = f (g x)
  10. let f4 = String.concat "-" << List.map string_of_int << List.rev << List.sort compare
  11.  
  12. let (>>) f g x = g (f x)
  13. let f5 = List.sort compare >> List.rev >> List.map string_of_int >> String.concat "-"
  14.  
  15. let () = List.iter (fun f -> print_endline @@ f [1;1;9;2]) [f1;f2;f3;f4;f5]
  16.  
Success #stdin #stdout 0s 5512KB
stdin
Standard input is empty
stdout
9-2-1-1
9-2-1-1
9-2-1-1
9-2-1-1
9-2-1-1