The Math Forum

Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Math Forum » Discussions » Inactive » comp.soft-sys.math.mathematica

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: Creating an ordered list of pairs
Replies: 4   Last Post: Dec 3, 2013 5:20 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Murray Eisenberg

Posts: 2,105
Registered: 12/6/04
Re: Creating an ordered list of pairs
Posted: Dec 2, 2013 1:44 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

Table together with Flatten will do what you want:

Flatten[Table[{i, 5 j}, {i, 1, 3}, {j, 1, 4}], 1]
= {{1,5},{1,10},{1,15},{1,20},{2,5},{2,10},{2,15},{2,20},{3,5},{3,10},{3,15},{3,20}}

An alternative to using indices with Table is to use Outer:

Flatten[Outer[List, Range[3], 5 Range[3]], 1]

On Dec 1, 2013, at 8:23 AM, amannucci <> wrote:

> How do I create an ordered list of pairs of the following structure:
> {{x1,y1}, {x2,y2}, {x3,y3}, ...} ? I want x1, x2, and x3 to be increasing in constant-interval steps (e.g. 1,2,3) and similarly for the y's (e.g. 5,10,15). E.g.
> {{1,5}, {1,10}, {1,15}, {2, 5}, {2,10}, ...} etc.
> I cannot figure out how to do this with Table or Array. Is there another function that will do this?
> Table does not create the correct nesting or structure.

Murray Eisenberg
Mathematics & Statistics Dept.
Lederle Graduate Research Tower
University of Massachusetts
710 North Pleasant Street
Amherst, MA 01003-9305

Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© The Math Forum at NCTM 1994-2018. All Rights Reserved.