Re: Q:Nicer than: Function[x,MapAt[Im,x,2]]/@data
- To: mathgroup at smc.vnet.net
- Subject: [mg5460] Re: Q:Nicer than: Function[x,MapAt[Im,x,2]]/@data
- From: Martin Rommel <rommel at bc.edu>
- Date: Sat, 7 Dec 1996 00:26:38 -0500
- Sender: owner-wri-mathgroup at wolfram.com
On Fri, 06 Dec 1996 17:40:56 +0100 Clemens Frey <Clemens.Frey at uni-bayreuth.de> wrote: > > > Hi, > > pattern matching can do a good job here. > Just having defined > > data = {{1.,I},{2,1+2*I}}; > > try the following: > > data /. {_Real,y_} -> Im[y] /. {_Integer,y_} -> Im[y] > > to get a list of imaginary parts of the second components > of the pairs in the list. > If you are sure that all first components are really Real > (other than in the example above!), then you can drop the > "/. {_Integer,y_} -> Im[y]" - thing. > I used _Real instead of _ alone to avoid problems with > lists of two pairs, on which {_,y_} would also match :-{. > > Hope this is what you needed > > Clemens > (-: Clemens.Frey at uni-bayreuth.de :-) Danke! Ich hatte schon vermutet dass es eine Unzahl von Moeglichkeiten gibt und haqbe eine Rieh von Vorschlaegen erhalten. Deiner ist neu! Mma ist schon beeindruckend vielfaelitg, ich wuerde gern mehr damit arbeiten. Tschuess, (oder ist das zu norddeutsch?) Martin.