0
$\begingroup$

I have a command

Table0[mS_]:=Table[{mS*i,i^2},{i,1,20}]
Table1=Join[Table0[1],Table0[2],Table0[3]]

When calling Table1[[1]] I expect to get the element Table0[1][[1]]. However, instead I get the whole Table[1]. How to split the tables?

$\endgroup$
  • $\begingroup$ Do you have a type in your second line ? Should Table there be Table0 ? $\endgroup$ – b.gates.you.know.what May 29 at 12:22
  • $\begingroup$ @b.gatessucks : thank you, I have corrected the code. $\endgroup$ – John Taylor May 29 at 12:24
  • $\begingroup$ Then it should work and Table1[[1]] -> {1, 1}. $\endgroup$ – b.gates.you.know.what May 29 at 12:27
  • 2
    $\begingroup$ Catenate[Table0 /@ Range[3]][[1]]=={1,1} $\endgroup$ – Alan May 29 at 12:50
0
$\begingroup$

Your statement is wrong.

Table0[mS_] := Table[{mS*i, i^2}, {i, 1, 20}]
Table1 = Join[Table0[1], Table0[2], Table0[3]]

returns a List of Length two List, as you expected.

Table1[[1]] === Table0[1][[1]]

returns True

What you describe would be the behavoir of List[...]. Alternatively you might have written Join[{...}] instead of Join@@{...}

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.