# Matching each function to each element [duplicate]

Assume that you have two lists of the same size where
1st contains functions for ex. {u,i,o,p}
2nd contains numbers for ex. {1,2,3,4}.
Create list such that each function is matched to each element:
{u[1], i[2], o[3], p[4]}

• Something like MapThread[#1[#2] &, {{u, i, o, p}, {1, 2, 3, 4}}] will work – Jason B. Jun 29 '17 at 18:52

Compose @@@ Transpose[{{u, i, o, p}, {1, 2, 3, 4}}]
Inner[Compose, {u, i, o, p}, {1, 2, 3, 4}, List]
MapThread[Compose, {{u, i, o, p}, {1, 2, 3, 4}}]
Module[{t = Thread[{##}]}, t[[All, 0]] = #@#2 &; t] &[{u, i, o, p}, {1, 2, 3, 4}]


all give

{u[1], i[2], o[3], p[4]}

You can use #@#2& in place of Compose above to get the same results.

Also, for fun,

☺ = # @ #2 & @@@ ({##}) &;


☺[{u, i, o, p}, {1, 2, 3, 4}]


{u[1], i[2], o[3], p[4]}

• Is # @ #2 & @@@ ({##}T) &; the same as #1[#2] & @@@ Transpose[##]&? – I should change my Username Jun 29 '17 at 21:17
• @IshouldchangemyUsername, almost. You need to change Transpose[##] to Transpose[{##}]. – kglr Jun 29 '17 at 21:19

This will also work:
Transpose[{{u, i, o, p}, {1, 2, 3, 4}}] /. {x_Symbol, y_Integer} -> x[y]