Is it possible to construct a pure function using multiple slots, with the following concept :
Binding specific slot to specific apply or map
For example :
In this example,
To reproduce the output for In(1), namely Out(1),
In[1] Table[Take[#, n], {n, 1, Length[#]}] & /@ test
Out[1] {{{4}, {4, 2}, {4, 2, 2}}, {{9}, {9, 1}, {9, 1, 5}},
{{5}, {5, 2}, {5, 2, 9}, {5, 2, 9, 3}},
{{5}, {5, 2}, {5, 2, 7}, {5, 2, 7, 1}, {5, 2, 7, 1, 1}}}
without using 'Table' symbol, I could do
In[2] Function[x, (Function[y, Take[x, y]] /@ Range[Length[x]])] /@ test
But I want to reproduce Out(1), only with slot symbols and Map.
The codes
((Take[#1, #2] &) /@ Range[Length[#1]]) & /@ test
or
((Take[#, #] &) /@ Range[Length[#]]) & /@ test
are tryable but they fails.
My imaginary working colored code is like :
Violet # binds to violet & and violet /@,
Green # binds to green & and green /@


Function[x, Take[x, #] & /@ Range[Length[x]]] /@ test– Daniel Huber Apr 01 '21 at 15:46FoldList[Append, {First@#}, Rest@#] & /@ testor i f you are a fan of cryptic code:(t = #; Take[t, #] & /@ Range[Length[#]]) & /@ test– Daniel Huber Apr 01 '21 at 16:30&with#is simply shorthand forFunctionwith a parameter, so theFunctionsolution is actually how you would bind a slot (in this case, namedx) in an anonymous function properly. – thorimur Apr 01 '21 at 17:20Slotto aFunctionconstructor&outside another constructor&("outside" being defined by syntactic precedence). As far as I know, at least. This came up before, but as I recall, it was not the central question, just the explanation of the problem with the OP's code. – Michael E2 Apr 01 '21 at 20:02Slot[]binds to the firstFunctiongoing up the expression tree to the head. To visualize your last example:(Take[#1, #1] &) /@ Range[Length[#1]] & // TreeFormThe firstSlot[1]inTake[..]won't bind to the topmostFunctionas desired. You would need a way to label the slots and the function, but such a way is already provided by symbolic arguments. – Michael E2 Apr 01 '21 at 20:11