I basically want to do this:

Function[{t}, f[t, #] & /@ {r1, r2, r4}] /@ {t1, t2, t3}

{{f[t1, r1], f[t1, r2], f[t1, r4]}, {f[t2, r1], f[t2, r2], f[t2, r4]}, {f[t3, r1], f[t3, r2], f[t3, r4]}}

I imagine there might be a more elegant way I might have missed, by mapping the matrix {{r1, r2, r4}, {t1, t2, t3}} directly onto the function f without the need of introducing 2 nested pure functions?

  • 6
    $\begingroup$ Outer[f, {t1, t2, t3}, {r1, r2, r4}] $\endgroup$
    – b3m2a1
    Mar 19, 2018 at 17:01
  • $\begingroup$ thats it. I always saw Outer only as the outer matrix product so far. Thanks! $\endgroup$
    – Mr Puh
    Mar 19, 2018 at 17:47

1 Answer 1

Partition[(f @@@ Tuples[{{r1, r2, r3}, {t1, t2, t3}}]), 3]

but b3m2a1's solution is better...


Not the answer you're looking for? Browse other questions tagged or ask your own question.