Special Product of two Lists

 Special Product of two Lists

One way would be

l1 = {{a,b},{c,d}};
l2 = {{{e,f},{g,h}},{{i,j},{k,q}}};

Partition[Riffle[l1,l1],2] l2
(* {{{a e, b f},{a g, b h}},{{c i, d j},{c k, d q}}} *)

The idea behind this solution is to expand l1 into the same shape as l2

Partition[Riffle[l1,l1],2]
(* {{{a,b},{a,b}},{{c,d},{c,d}}} *)

and then use Mathematicas builtin elementwise multiplication on similar shaped lists to get the result.

Let’s block ads! (Why?)

Recent Questions – Mathematica Stack Exchange