To evaluate the function f for all pairs from the two lists l1 and l2 , use Outer :
In[1]:= Outer[f, {a,b}, {x,y,z}] Out[1]:= {{f[a,x],f[a,y],f[a,z]}, {f[b,x],f[b,y],f[b,z]}}
Outer by default, runs at the lowest level of lists provided; you can also specify the level with an additional argument:
In[2]:= Outer[f, {{1, 2}, {3, 4}}, {{a, b}, {c, d}}, 1] Out[2]:= {{f[{1,2},{a,b}], f[{1,2},{c,d}]}, {f[{3,4},{a,b}], f[{3,4},{c,d}]}}
Note that this creates a nested list; You can Flatten if you want.
My original answer pointed to Thread and MapThread , which are two ways to apply a function to the corresponding pairs from lists, for example MapThread[f,{a,b},{1,2}] == {f[a,1], f[b,2]} .
PS I think that by studying these things you will find the documentation very useful. There are many common topic pages, such as applying functions to lists and manipulating a list . They are usually linked in the โmoreโ section at the bottom of specific documentation. This greatly facilitates the search for things when you do not know what they will be called.