Create matrix of strings by a method analogous to matrix multiplication [closed]

I have 2 lists of strings, say, the first is {“D1″,”D2″,”D3”} and the second is {“P1”, “P2″,”P3”}. I want to create

D1P1 D1P2 D1P3
D2P1 P2P2 D2P3
D3P1 D3P2 D3P3

where the elements “D1P1”, etc., are strings. This seems to call for something analogous to matrix outer multiplication, but using String Concatenation instead of Times. How might I do this?



1 Answer


Using Outer,

Outer[StringJoin, {“D1”, “D2”, “D3”}, {“P1”, “P2”, “P3”}]
(* {{“D1P1”, “D1P2”, “D1P3”}, {“D2P1”, “D2P2”, “D2P3”}, {“D3P1”,
“D3P2”, “D3P3”}} *)