Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2013

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Creating a list of 1x2 element arrays without

  • To: mathgroup at smc.vnet.net
  • Subject: [mg132075] Re: Creating a list of 1x2 element arrays without
  • From: Bob Hanlon <hanlonr357 at gmail.com>
  • Date: Mon, 2 Dec 2013 01:55:41 -0500 (EST)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • Delivered-to: l-mathgroup@wolfram.com
  • Delivered-to: mathgroup-outx@smc.vnet.net
  • Delivered-to: mathgroup-newsendx@smc.vnet.net
  • References: <20131201132345.2493B6A0D@smc.vnet.net>

Use Flatten or Join


latlong = Flatten[
  Table[{lat, long},
   {lat, 30., 45., 5.},
   {long, -270., -240., 10.}],
  1]


{{30., -270.}, {30., -260.}, {30., -250.}, {30., -240.}, {35., -270.},
{35., \
-260.}, {35., -250.}, {35., -240.}, {40., -270.}, {40., -260.}, {40.,
-250.}, \
{40., -240.}, {45., -270.}, {45., -260.}, {45., -250.}, {45., -240.}}


or


latlong = Join @@ Table[{lat, long},
   {lat, 30., 45., 5.},
   {long, -270., -240., 10.}]


{{30., -270.}, {30., -260.}, {30., -250.}, {30., -240.}, {35., -270.},
{35., \
-260.}, {35., -250.}, {35., -240.}, {40., -270.}, {40., -260.}, {40.,
-250.}, \
{40., -240.}, {45., -270.}, {45., -260.}, {45., -250.}, {45., -240.}}


% == %%


True



Bob Hanlon




On Sun, Dec 1, 2013 at 8:23 AM, amannucci
<Anthony.J.Mannucci at jpl.nasa.gov>wrote:

> Is there a way in Mathematica using built-in functions to create what the
> following procedural program does?
>
> latlong = {}
> Do[AppendTo[latlong, {i, j}] , {i, 30.0, 45.0,
>    5.0}, {j, -270.0, -240.0, 10.0}];
> latlong
>
> Out:
> {{30., -270.}, {30., -260.}, {30., -250.}, {30., -240.}, {35., \
> -270.}, {35., -260.}, {35., -250.}, {35., -240.}, {40., -270.}, {40., \
> -260.}, {40., -250.}, {40., -240.}, {45., -270.}, {45., -260.}, {45., \
> -250.}, {45., -240.}}
>
> Thanks!
>
> -Tony
>
>


  • Prev by Date: Creating a list of 1x2 element arrays without procedural programming
  • Next by Date: Re: Creating an ordered list of pairs
  • Previous by thread: Creating a list of 1x2 element arrays without procedural programming
  • Next by thread: Re: Creating a list of 1x2 element arrays without