Mathematica - turning two lists into an array

Click For Summary
SUMMARY

The discussion focuses on transforming two lists in Mathematica into an array format. The user initially attempted to use the Riffle function, which interleaves the lists but does not achieve the desired output. The solution provided is to utilize the Transpose function with the syntax Transpose[{{a1, a2, a3}, {b1, b2, b3}}], which correctly formats the lists into pairs, resulting in {{a1, b1}, {a2, b2}, {a3, b3}}.

PREREQUISITES
  • Familiarity with Mathematica syntax
  • Understanding of list data structures in Mathematica
  • Knowledge of the Transpose function in Mathematica
  • Basic programming concepts related to data manipulation
NEXT STEPS
  • Explore additional list manipulation functions in Mathematica
  • Learn about the Riffle function and its applications
  • Investigate advanced data structures in Mathematica
  • Practice using Transpose with different data types and structures
USEFUL FOR

This discussion is beneficial for Mathematica users, data analysts, and programmers looking to manipulate lists and arrays effectively within the Wolfram Language.

tomrob123
Messages
1
Reaction score
0
Hi

I need to turn two lists in the form {a1,a2,a3...} {b1,b2,b3...}
into {{a1,b1},{a2,b2},{a3,b3}..}

I've looked everywhere on the Wolfram website and the best i found was:

Riffle[{list1},{list2}] which gives me {a1,b1,a2,b2,a3,b3}

does anyone know the function to use?

Thanks
 
Physics news on Phys.org
Hi,
Maybe this:
Transpose[{{a1, a2, a3}, {b1, b2, b3}}]
 
Equivalently, {{a1, a2, a3}, {b1, b2, b3}}TR. (The transpose symbol comes from hitting Esc, tr, Esc.)
 

Similar threads

Replies
3
Views
4K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 8 ·
Replies
8
Views
5K
  • · Replies 8 ·
Replies
8
Views
2K
  • · Replies 3 ·
Replies
3
Views
3K
  • · Replies 10 ·
Replies
10
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K