I have a pure function

f:= #1 * #2 * #3 &;

Which I can invoke in a following way:

f[#,2,3]& /@ {1,2,3}

Which yields following result:

{6, 12, 18}

How could I do something like this:

f[#1,#2,3]& /@ {{1,2,3},{1,2,3}}

such that the return product would look like:

{{3,6,9},{6,12,18},{9,18,27}}

I understand there is a syntax error above. I struggle coming up with a functional solution which would avoide iteration and loops. I’d greatly appreciate any assistance.

Example based on OOP (conceptual):

List

for(int i = 1; i < 5; i++){
for(int m = 1; m < 3; m++){
product = i * m * 3;
nums.add(product)
}
}
System.out.println("Product: " + nums.toString());
=================
2
If you want all combinations of possible #1 and #2, use Outer.
– Marius Ladegård Meyer
Jun 15 '15 at 16:16
mathematica.stackexchange.com/questions/85165/… deals with this problem
– BlacKow
Jun 15 '15 at 16:27
=================
1 Answer
1
=================
As mentioned in the comments, the construct you are probably looking for is Outer (see its documentation page).
You could then define the following function to achieve what you indicated, even without using Map:
Clear[func]
func[list1_List, list2_List, factor_?NumberQ] := factor Outer[Times, list1, list2]
func[{1, 2, 3}, {1, 2, 3}, 3]
(* Out: {{3, 6, 9}, {6, 12, 18}, {9, 18, 27}} *)