Message Boards Message Boards

Insert or Joint a element in a table

7 Replies
Posted 9 years ago
POSTED BY: Bill Simpson
Posted 9 years ago
POSTED BY: Bill Simpson
Posted 9 years ago
POSTED BY: David Keith

Ooops, that is a tricky one!

aa = {{{a, b}, {c, d}, {e, f}}, {{1, 2}, {3, 4}, {5, 6}}};
t = {x, z};

Flatten /@ # & /@ Thread /@ Thread[{aa, t}]

... well, I prefer Davids solution!

Henrik

POSTED BY: Henrik Schachner

Here probably the same question: How to insert elements of a list into list of lists?

MapThread[Flatten /@ Thread[{##}] &, {aa, t}]
{{{a, b, x}, {c, d, x}, {e, f, x}}, {{1, 2, z}, {3, 4, z}, {5, 6, z}}}
POSTED BY: Kuba Podkalicki

Thank you a lot !

Flatten always scares me with regards to scalability, thus I prefer

Append @@@ # & /@ Thread /@ Transpose[{aa, t}]
POSTED BY: David Gathercole
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract