1
$\begingroup$

How is it possible to create a list of {x,y} points as the following one:

list={{1,1},{1,2},...,{1,100},{2,1},{2,2},...,{2,100},...,{100,1},{100,2},...,{100,100}}

Thanks

$\endgroup$
5
  • 1
    $\begingroup$ Table[{i,j}, {i, 100}, {j, 100}]? What have you tried? $\endgroup$
    – C. E.
    Commented Feb 27, 2017 at 16:23
  • $\begingroup$ Hi, I was using Range, but it doesn't work for 2D lists. However, you answer gives my some additional brackets that are unwanted, like this: {{{1,1},{1,2},...,{1,100},{2,1},{2,2},...,{2,100},...,{100,1},{100,2},...,{100,100}}}. I've found the way with Flatten[]. Thanks for your help! $\endgroup$
    – MicheleG
    Commented Feb 27, 2017 at 16:45
  • $\begingroup$ Not an exact duplicate but a more general topic. Let me know if you disagree with closing. $\endgroup$
    – Kuba
    Commented Feb 27, 2017 at 16:46
  • $\begingroup$ @Michele You need to Flatten the result; consider Flatten[Table[{i, j}, {i, 1, 100}, {j, 100}], 1]. More in general, also take a look at the proposed duplicate. $\endgroup$
    – MarcoB
    Commented Feb 27, 2017 at 16:49
  • $\begingroup$ Join @@ Array[List , {100, 100} ] $\endgroup$
    – user1066
    Commented Feb 27, 2017 at 20:24

1 Answer 1

4
$\begingroup$
Tuples[Range[100], 2]

or using Table as mentioned in the comment

It is worth noting that the method relying on Tuples is 10-12 times faster than Table

$\endgroup$

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