Given
t1 = {2, 4, 8, 16};
t2 = {1, 5, 9};
First[Select[t1, # > 1 &]]
First[Select[t1, # > 5 &]]
First[Select[t1, # > 9 &]]
can somehow be summarized by
Table[First[Select[t1, # > x &]], {x, t2}]
to get the correct result
{2, 8, 16}
Is there a way to use two pure functions connected instead of working around the problem by using Table
?
Something like (which does not work!):
First[Select[t1, # > # &] & /@ t2]
With[{x=#},SelectFirst[t1,#>x&]]&/@t2
$\endgroup$#
, because technically pure functions are not supposed to affect mutable state or produce different values given identical arguments, but Mathematica's 'pure' functions can do this, e.g:x = 1; f = (++x; x + #) &; {f[1],f[1],f[1]}
$\endgroup$