Community
Participate
Working Groups
What about adding direct/reversed infix application operators. As an example (using caml symbols), the direct application operator <| is defined as: f <| x = f(x) with right priority, the reverse application operator |> is defined as: x |> f = f(x) with left priority, Such that a function call: h(g(f (x))) can be written h <| g <| f<| x or x |> f |> g |> h (Unix like) What do you think? ---- jponge commented on 27 Oct 2014 Why not. How does it work with more than 1 parameter? In any case it's worth exploring! ---- yloiseau commented on 27 Oct 2014 For easy composing of functions, they should have only one argument (which can be a tuple :smile:). However, all this can already be written as f:andThen(g):andThen(h)(x) e.g. let f = |x| -> x + 1 let g = |x| -> 2 * x let h = |x| -> "answer: " + x require(h(g(f(20))) == "answer: 42", "err") require(f:andThen(g):andThen(h)(20) == "answer: 42", "err") or using a HOF to do the hard work: let pipe = |funcs...| -> atoList(funcs): reduce( |x| -> x, |f, g| -> f:andThen(g) ) require(pipe(f, g, h)(20) == "answer: 42", "err") So it may not be necessary after all ---- yloiseau commented on 27 Oct 2014 Btw I'm currently builing a golo lib with useful hof and generic generators, with among other things this pipe function, a curry/uncurry one, and one to convert n-ary functions into a unary function taking a tuple and the other way (useful for composing) ----