Given two lists $l_a = \{a_1, a_2, a_3\}$, $l_b = \{b_1, b_2, b_3, b_4\}$ and some function $f$ accepting two arguments, how can I produce a list of all values $f(a, b)$ for $a\in l_a$ and $b \in l_b$ using functional construction?
Tell me more
×
Mathematica Stack Exchange is a question and answer site for
users of Mathematica. It's 100% free, no registration required.
|
You could do
or
or
|
|||||||
|
|
While
|
|
If the intent doesn't imply nesting them, a nice one is also ReplaceList[{{1, 2, 3}, {a, b}}, {{___, a_, ___}, {___, b_, ___}} :> {a, b}] – Rojo Dec 22 '12 at 15:40 |
||
@Rojo Similar to this answer which as you'll note I liked. May I include that in my answer? – Mr.Wizard♦ Dec 23 '12 at 3:11 |
|||
@Rojo for some reason I'm not getting @notifications today. I looked at that answer briefly but I intended to return to it. In the context of a larger Grid layout I believe that different sections will not align. Sorry for not being responsive to your answer without prompting. – Mr.Wizard♦ Dec 23 '12 at 11:25 |
|

Outer[f,la, lb]wherelaandlbare your lists – rm -rf♦ Dec 21 '12 at 20:22Outerusing functional style? – Jarek Miszczak Dec 21 '12 at 20:32f[#, k] & /@ {x1,x2}/. k -> # & /@ {y1, y2, y3}? – belisarius Dec 21 '12 at 20:45/. k -> # &– Jarek Miszczak Dec 21 '12 at 21:07