0
$\begingroup$

I want to do the following

Select[#1, x0min < #1[[#2]] < x0max &][[All, {1, #2}]] &  [listData, 2]

where I pick only those elements from a given list listData that lie within a certain range defined by x0min and x0max. With only one slot #1this works well if I insert the second placeholder by hand.

Why isn't it working with two slots?

I want something like

f[#1, #2] & [1, 2]

where f contains Select.

$\endgroup$
  • $\begingroup$ In Select[#1, x0min < #1[[#2]] < x0max &] the second slot #2 is never populated. Select takes each element from #1 and passes it to the function in the second argument, it doesn't pass two values. Maybe you want to pass in information from the outer anonymous function, in which case the syntax with named parameters can help you Function[{x,y}, f[x,y]]. $\endgroup$ – C. E. May 15 '17 at 17:42
  • $\begingroup$ Alright, that explains why it does not work. Do you mean something like Function[Select[#1, x0min < #1[[#2]] < x0max &][[All, {1, #2}]] & [ listData2[wi]]][2]? My listData contains several columns and for each column pair 1,2 and 1,3 etc. I want to pick the points with Select and later on join the lists together. $\endgroup$ – Display Name May 15 '17 at 17:46
  • $\begingroup$ f.e. Function[{x, y}, Select[x, #[[y]] &][listData, 2] would pass 2 into the inner anonymous function. The point is that when you nest two anonymous functions without named parameters, then you have a naming collision in the inner anonymous function and cannot retrieve the arguments of the outer anonymous function. $\endgroup$ – C. E. May 15 '17 at 17:49
  • 1
    $\begingroup$ I'd mark it as a duplicate: mathematica.stackexchange.com/q/28983/5478 maybe the question isn't the same but it is the same issue. $\endgroup$ – Kuba May 15 '17 at 17:55
  • 1
    $\begingroup$ Thank you C.E., it works now like a charm. So in my specific example there is no way to work merely with pure functions, right. You always need to rely on the syntax with named parameters? $\endgroup$ – Display Name May 15 '17 at 17:59

Browse other questions tagged or ask your own question.