marferit
(margherita ferrucci)
1
Hi,
I have
cpQ = {{{a,b},{c,d},{e,f}},{{g,h},{l,m }}}
and
tt = {x,y}
I would sum each cpQ couple to tt. In fact I want translate cpQ.
But if I write
cpQ = Plus [ #,tt] &/@ cpQ
It doesn’t work. Which is the solution? Where is the miscalculation?
Thank for your help
Margherita
Hard to figure what you mean. Perhaps this?
Plus[tt, #] & /@ Flatten[cpQ, 1]
marferit
(margherita ferrucci)
3
Thank you for your suggestion.
I’d like obtain:
CpQ = { { {a+x, b+y},{c+x,d+y},{ e+x , f+y} } , { {g + x ,h+y },{l+x ,m+y } } }
If I use your command I have
CpQ = {{a+x, b+y},{c+x,d+y} , { e+x , f+y} , {g + x ,h+y },{l+x ,m+y } }
It isn’t the same because I lost the parenthesis.
The CpQ shape seems unbalanced:
cpQ // TableForm
I am not sure if this is a typo.
I guess you could wrap brackets around my previous code:
{Plus[tt, #] & /@ Flatten[cpQ, 1]}
marferit
(margherita ferrucci)
5
Thank you, but it isn’t the same.
I search this
CpQ = { { {a+x, b+y},{c+x,d+y},{ e+x , f+y} } , { {g + x ,h+y },{l+x ,m+y } } }
with tt ={x,y},
but your result code is
CpQ = { { {a+x, b+x},{c+x,d+x},{ e+x , f+x} } , { {g + y ,h+y },{l+y ,m+y } } }
We are near the correct form, but it isn’t the final yet.
iliang
(Ilian Gachevski)
6
In[2]:= Map[# + {x, y} &, {{{a, b}, {c, d}, {e, f}}, {{g, h}, {l, m}}}, {2}]
Out[2]= {{{a + x, b + y}, {c + x, d + y}, {e + x, f + y}}, {{g + x, h + y}, {l + x, m + y}}}