Re: Manipulating a list of pairs
- To: mathgroup at smc.vnet.net
- Subject: [mg19733] Re: [mg19689] Manipulating a list of pairs
- From: BobHanlon at aol.com
- Date: Mon, 13 Sep 1999 02:41:01 -0400
- Sender: owner-wri-mathgroup at wolfram.com
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?
>