Quantcast
Channel: bind specific 'Slots' to specific 'Map' - Mathematica Stack Exchange
Viewing all articles
Browse latest Browse all 3

bind specific 'Slots' to specific 'Map'

$
0
0

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 :

enter image description here

In this example,

To reproduce the output for In(1), namely Out(1),

In[1] Table[Take[#, n], {n, 1, Length[#]}] & /@ testOut[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 :

enter image description here

Violet # binds to violet & and violet /@,
Green # binds to green & and green /@


Viewing all articles
Browse latest Browse all 3

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>