1
$\begingroup$

This question already has an answer here:

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?

$\endgroup$

marked as duplicate by b3m2a1, m_goldberg, Bob Hanlon, José Antonio Díaz Navas, Kuba list-manipulation Mar 20 '18 at 12:01

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

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

but b3m2a1's solution is better...

$\endgroup$

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