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 procedural programming

  • To: mathgroup at smc.vnet.net
  • Subject: [mg132086] Re: Creating a list of 1x2 element arrays without procedural programming
  • From: Roland Franzius <roland.franzius at uos.de>
  • Date: Mon, 2 Dec 2013 01:59:22 -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: <l7fckt$k44$1@smc.vnet.net>

Am 01.12.2013 14:13, schrieb amannucci:
> 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.}}

Some more constructs

latlong = {};
Do[AppendTo[latlong, {i, j}], {i, 30.0, 45.0,
    5.0}, {j, -270.0, -240.0, 10.0}];

table = Flatten[
    Table[{i, j}, {i, 30.0, 45.0, 5.0}, {j, -270.0, -240.0, 10.0}], 1];

array = Flatten[Array[{25.0 + 5 #1, -280.0 + 10 #2} &, {4, 4}], 1];

outer = Flatten[
    Outer[List, Range[30.0, 45.0, 5.0], Range[-270.0, -240.0, 10.0]],
    1];

functions1 =
   Flatten[Function[ x, {x, #1} & /@ Range[-270.0, -240.0, 10.0]] /@
     Range[30.0, 45.0, 5], 1];

vectors = ({25.0, -280.0} + # &) /@
    Flatten[Outer[List, ##] & @@ ((Range[1, 4]*# &) /@ {5, 10}), 1];

flc = Flatten[
    Outer[List, ##] & @@ (({5 #, 10 #} &)[
        Range[1, 4]] + {25.0, -280.0}), 1];


latlong == table == array == outer == functions == vectors == flc


True

-- 

Roland Franzius



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