Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
1998
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 1998

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

Search the Archive

RE: List handling

  • To: mathgroup at smc.vnet.net
  • Subject: [mg15275] RE: [mg15261] List handling
  • From: "Ersek, Ted R" <ErsekTR at navair.navy.mil>
  • Date: Thu, 31 Dec 1998 04:39:31 -0500
  • Sender: owner-wri-mathgroup at wolfram.com

Jorge Zickermann  was trying to do some list manipulation.

The code below should work nicely.
Note: (I use ListA not listA)

In[41]:=
CombinedList=Transpose[{ListA,ListB,ListC}];
CombinedList=CombinedList/.{A_,B_?(#>0.68&),C_}:>{C,B,C};
ListA=Map[#[[1]]&, CombinedList]

Out[41]=
{1971.45,1973.53,1977.06,1977.06,1977.06,2044.23,2047.77,
2047.77,2047.77,2181.55,2181.55,2181.55,2244.73,2244.73,
2244.73,2305.5,2305.5,2305.5,2305.5,2363.92,2363.92,
2363.92,2363.92,2363.92,2363.92,2363.92,2363.92,
2363.92,2363.92,2363.92}

Note:
If you are very concerned about speed and not so concerned about "clean"
code you can use the following instead of the middle line:
CombinedList=CombinedList/.{_,_?(#>0.68&),C_}:>{C,0,0};


Cheers,
Ted Ersek

_____________________

listA=
{1977.06,1977.06,1977.06,1977.06,1977.06,2047.77,
2047.77,2047.77,2047.77,2181.55,2181.55,2181.55,
2244.73,2244.73,2244.73,2305.5,2305.5,2305.5,2305.5,
2363.92,2363.92,2363.92,2363.92,2363.92,2363.92,
2363.92,2363.92,2363.92,2363.92,2363.92}

ListB=
{0.684807,0.683029,0.665242,0.665242,0.664123,
0.683029,0.665242,0.665242,0.664123,0.640339,
0.640339,0.620329,0.640339,0.640339,0.620329,
0.661684,0.640339,0.640339,0.620329,0.640339,
0.622044,0.640339,0.621506,0.660996,0.640339,
0.641006,0.640339,0.620935,0.640339,0.640339}

ListC=
{1971.45,1973.53,1994.29,1994.29,1995.6,
2044.23,2065.,2065.,2066.3,2227.86,2227.86,
2251.22,2291.04,2291.04,2314.4,2326.89,
2351.81,2351.81,2375.17,2410.22,2431.58,
2410.22,2432.21,2386.11,2410.22,2409.44,
2410.22,2432.88,2410.22,2410.22}

Position[ListB,_?(#>0.68&)]

{{1},{2},{6}}

Having obtained the positions of certain selected elements from ListB, I
want to substitute the corresponding elements in ListA by the
corresponding elements in ListC. In other words, I want to end up with;

listA= 
{1971.45,1973.53,1977.06,1977.06,1977.06,
2044.23,2047.77,2047.77,2047.77,2181.55,
2181.55,2181.55,2244.73,2244.73,2244.73,
2305.5,2305.5,2305.5,2305.5,2363.92,
2363.92,2363.92,2363.92,2363.92,2363.92,
2363.92,2363.92,2363.92,2363.92,2363.92}

Any help on how to do this is welcome. Thank you.

    Jorge


  • Prev by Date: CellGrouping default
  • Next by Date: Style sheet problem
  • Previous by thread: Re: List handling
  • Next by thread: Re: List handling