MathGroup Archive 2013

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

Search the Archive

Re: Creating a list of 1x2 element arrays without procedural programming


On 12/1/2013 7:13 AM, amannucci 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
>

many ways. One way

lst1 = Range[30.0, 45.0, 5.0];
lst2 = Range[-270.0, -240.0, 10.0];
Flatten[Map[ Thread[{#, lst2}] &, lst1], 1];

--Nasser




  • Prev by Date: Re: Creating a list of 1x2 element arrays without procedural programming
  • Next by Date: Re: Cubic Bezier Curves Intersection
  • Previous by thread: Re: Creating a list of 1x2 element arrays without procedural programming
  • Next by thread: Parameters for the Stereographic projection in GetProjectionData