The Elixir |> (pipeline / nose) operator. Makes functional programming much cleaner without brackets or intermediate variables. I wish more programming language has this. JavaScript comes close with chained calls of map.
```ocaml
type point = { x: float; y: float};;
let euclidean a a' =
let xd = (a'.x -. a.x) in
let yd = (a'.y -. a.y) in
sqrt ((xd*.xd) +. (yd*.yd))
;;
let is_in_unit_circle x =
x <= 1.
let quadsolve iterations hits =
((4. *. hits) /. Float.of_int iterations)
let estimate iters =
let origin = { x = 0.; y = 0. } in
Array.init iters (fun _ -> { x = (Random.float 1.); y = (Random.float 1.) })
|> Array.map (euclidean origin)
|> Array.map is_in_unit_circle
|> Array.fold_left (fun x y -> if y then x +. 1. else x ) 0.
|> quadsolve iters
;;```
utop # estimate 1000000;;
- : float = 3.141432
Edit: formattingThere's a long-standing TC39 proposal to add it to JS. It's interesting to read it to see examples of the aforementioned differences.