# Combining $n$ lists [closed]

From this question, I know how to combine two lists. In fact, if $X_1,X_2, X_3$ are lists with the same length, then the command Transpose[X_1,X_2,X_3] will work in a similar way, but for 3 entries. Now suppose I want to use $n$ lists and want to use the transpose command for $n$. The value of $n$ is a parameter, so it can be changed, how do I work this?

To be concrete, below is a pseudo-Mathematica code of what I want to implement.

n=10 For[i=1, i<=n, i++{ X_i = RandomReal[{-1,1}, 25] }] X=Transpose[X_1,...,X_n]

Each $X_i$ can be written as $X_i=[x_{i,1},\ldots,x_{i,25}]$, where each entry $x_{i,j}$ is random. Note that $X$ can be written as $X=\Big[ \{x_{1,1},x_{2,1}, \ldots,x_{n,1}\},\ldots, \{x_{1,25},x_{2,25},\ldots,x_{n,25}\} \Big]$, in words, $X$ is a list with 25 entries, each entry is another list with 10 numbers (because $n=10$ in this example) randomly generated.

The main problems is that I don't know how to create indexed lists and I don't know how to make this general transpose work.

## closed as off-topic by MarcoB, Bob Hanlon, m_goldberg, dr.blochwave, Yves KlettJun 19 '15 at 7:33

This question appears to be off-topic. The users who voted to close gave this specific reason:

• "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – MarcoB, Bob Hanlon, m_goldberg, dr.blochwave, Yves Klett
If this question can be reworded to fit the rules in the help center, please edit the question.

• n = 10; For[i = 1, i <= n, i++, x[i] = RandomReal[{-1, 1}, 25]]; Transpose[x /@ Range@n];, but whay bother with such machinations when RandomReal[{-1,1},{25,10}] nets the same result? – ciao Jun 18 '15 at 22:46
• There is a good reason for that, I wasn't aware of that command. – Integral Jun 18 '15 at 22:47

You seem to be working very hard for what seems to be this:

Table[RandomReal[], {i,n}]

• LOL - see commnent on OP, +1 – ciao Jun 18 '15 at 22:47
• Thank you for the help, looks like I have a lot learn! – Integral Jun 18 '15 at 22:49

Just for the record, there is a functionality in Mathematica if you want to apply a function to a variable number of arguments. This is actually the Apply or @@ operation. It works like:

f @@ {a,b,c}
(* f[a,b,c] *)


For example, if for any reason you need something along the lines of your Pseudo code; or you really have a variable number of lists containing real data to work with, you can try with Join for example:

X = {};
For[i = 1, i <= 25, i++, X = Append[X, RandomReal[{-1, 1}, 25]]];
Join @@ X


In which case all 25 lists are passed as individual arguments to Join.

You can create the lists that you want and then use Join[list1,list2,...] to combine them.

Since each list will combine of $n$ elements, you can use the following lines to create them:

n=10;
list1=Table[RandomReal[],n]
list2=...