Group Abstract Group Abstract

Message Boards Message Boards

0
|
9.7K Views
|
4 Replies
|
1 Total Like
View groups...
Share
Share this post:

Interweave two lists in Mathematica?

Posted 9 years ago

Hi all, I am a student who is undertaking the project EOG and I'm stuck because I'm new in Mathematica. I need a code that divide two vectors such as

x = {1,2,3, ...}; y = {a, b, c, ...} 

in a list such that

list = {{1, a}, {2, b}, {3, c}, ...}

Can someone help me? Thanks in advance by your attention

POSTED BY: Fernando Sanchez
4 Replies

Just for variety, another way:

 Partition[Riffle[Range[3], {a, b, c}], 2]

P.S. Please use a more informative question topic than "I need help with mathematica". For example: "How interweave two lists in Mathematica?"

POSTED BY: Murray Eisenberg
In[1]:= Thread[{{1, 2, 3}, {a, b, c}}]

Out[1]= {{1, a}, {2, b}, {3, c}}
POSTED BY: Frank Kampas

What have you tried? Did you even try to search documentation? For example:

http://reference.wolfram.com/language/ref/Transpose.html

http://reference.wolfram.com/language/ref/Thread.html

x = {1, 2, 3}; y = {a, b, c};
Transpose[{x, y}]
Thread[{x, y}]

You should really start from minimal effort to learn docs and for example to see this:

https://www.wolfram.com/language/fast-introduction-for-programmers

POSTED BY: Sam Carrettie

That is easy:

Transpose[{x, y}]
POSTED BY: Gustavo Delfino
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard