programming_languages/sml/week1/operators.sml
2020-06-02 03:39:00 +03:00

17 lines
No EOL
343 B
Standard ML

(*
Pipe operator.
Simply to write code like "data |> fun" instead "fun data".
Then you can "pipe" results to functions via partial application:
fun square a b = a * b
fun sum a b = a + b
10 |> sum 10 |> square 2 // 40
*)
fun |> (x, f) = f x
(* composition operator *)
fun $ (f, x) = f x
infix |>
infix $