Apply MapThread to all but one variable
Here's one way to do it with Outer
:
n = 3;
l1 = Array[a, n];
l2 = Array[b, n];
l3 = Array[c, n];
Outer[
f[#1[[1]], #1[[2]], #2] &,
Transpose @ {l1, l2},
l3,
1
]
Out[25]= {{f[a[1], b[1], c[1]], f[a[1], b[1], c[2]], f[a[1], b[1], c[3]]}, {f[a[2], b[2], c[1]], f[a[2], b[2], c[2]], f[a[2], b[2], c[3]]}, {f[a[3], b[3], c[1]], f[a[3], b[3], c[2]], f[a[3], b[3], c[3]]}}
a = {a1, a2, a3, a4, a5};
b = {b1, b2, b3, b4, b5};
c = {c1, c2, c3, c4, c5};
Table[f[a[[j]], b[[j]], c[[k]]], {j, 1, 5}, {k, 1, 5}]
Another possibility is to use the 3-arg version of Thread
. With Sjoerd's example:
n = 3;
l1 = Array[a,n];
l2 = Array[b,n];
l3 = Array[c,n];
Using Thread
:
Thread /@ Thread[f[l1, l2, l3], List, 2]
{{f[a[1], b[1], c[1]], f[a[1], b[1], c[2]], f[a[1], b[1], c[3]]}, {f[a[2], b[2], c[1]], f[a[2], b[2], c[2]], f[a[2], b[2], c[3]]}, {f[a[3], b[3], c[1]], f[a[3], b[3], c[2]], f[a[3], b[3], c[3]]}}