How to distinguish a slot in several levels of pure functions in mathematics

For example, I may have

{1, 2, 3, 4, 5} // Select[#1, ((*** + 1 &) > 2) &] &

It ***also wants to be # 1, but not recognized as the topmost layer # 1. Is there a way to distinguish two?

Thank.

+3
source share
2 answers

I'm not sure I understand this question. What is your expected result? .. {2,3,4,5}? ... If so, there is no logical confusion between the slots: each element in the list that the first argument Selectwill be passed to the function (second argument). The following works perfectly:

{1, 2, 3, 4, 5} // Select[#, ((# + 1) > 2) &] &

In the event of a conflict, instead of designating slots / ampersands, you can use notation Function[{x,y,...},...], for example.

{1, 2, 3, 4, 5} // Select[#, Function[{x}, (x + 1) > 2]] &

+6
source

,

{1, 2, 3, 4, 5} // Select[#1, ((# + 1) > 2) &] &

, #1 . , #1 # .

((# + 1&) > 2)& , . (F > 2)&, F - , . ((# + 1&[#]) > 2)&, (F[#] > 2)&.

+3

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


All Articles