MathGroup Archive 1999

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

Search the Archive

Re: Manipulating a list of pairs


Hans,

lumpi[{f_, amp_}] := {f, Power[2 Pi f, 2] U / amp};

thelist = 
    Table[ToExpression[
        "{x" <> ToString[k] <> ", y" <> ToString[k] <> "}"], {k, 5}];

The following expressions are equivalent

lumpi /@ thelist == 
  ({#1[[1]], (2*Pi*#1[[1]])^2*U/#1[[2]]} & ) /@ thelist == 
  (thelist /. {x_, y_} :> {x, (2*Pi*x)^2*U/y}) == 
  Cases[thelist, {x_, y_} :> {x, (2*Pi*x)^2*U/y}] == 
  MapThread[{#1, (2*Pi*#1)^2*U/#2} & , Transpose[thelist]]

True

However, I don't think they are any easier nor are they any easier to 
understand.

Bob Hanlon

In a message dated 9/11/1999 9:42:15 PM, 
hans.steffani at e-technik.tu-chemnitz.de writes:

>I have a list of pairs and manipulate it with things like
>
>lumpi[{f_, amp_}]:={f, Power[2 Pi f,2] U / amp}
>Map[ lumpi, thelist]
>
>is there an easier way without introducing "lumpi" to do this?
>


  • Prev by Date: Re: compressed list output
  • Next by Date: Re: contourplots
  • Previous by thread: Re: Manipulating a list of pairs
  • Next by thread: Re: Manipulating a list of pairs