What is the point of the rear pipe operator

LiveScript contains both the forward and reverse piping operator . The purpose of the direct pipeline is obvious: [1, 2, 3] |> reverse |> tail |> sumtranslated and much clearer than sum(tail(reverse([1, 2, 3])));.

However, the goal of the return pipeline is mysterious to me: sum <| tail <| reverse <| [1, 2, 3]exactly the same as soon as sum tail reverse [1, 2, 3], and as far as I can tell about the differences in priority.

So what is the purpose of the statement <|in LiveScript?

+4
source share
1 answer

This is useful as a section when you want to create a function that applies its argument to a value:

map (<| Math.PI), [(1 +), (2 -), (3 *), (4 /)]

It is also consistent; there |>so that you can expect that the opposite will also exist.

+3
source

Source: https://habr.com/ru/post/1584225/


All Articles