Re: Complex Numbers to list of points

*To*: mathgroup at smc.vnet.net*Subject*: [mg72192] Re: Complex Numbers to list of points*From*: "Mark Westwood" <markc.westwood at gmail.com>*Date*: Thu, 14 Dec 2006 05:49:07 -0500 (EST)*References*: <elosbs$ojk$1@smc.vnet.net>

Andrew Try the following: {1+3i, 2, 1-3i} /. (z_ /; NumericQ[z]) -> {Re[z], Im[z]} which gives me {{1, 3}, {2, 0}, {1, -3}} Note the () around the pattern with condition. HTH Mark Westwood On 13 Dec, 12:40, planetmarshal... at hotmail.com wrote: > Hi there, > > I have a list of mixed complex and real numbers returned from a function, e= > g > > {1+3i, 2, 1-3i} > > I wish to convert the list to a list of points. > > {1+3i,2,1-3i} /. z_Complex->{Re[z],Im[z]} > > gives > > {{1,3},2,{1,-3}} > > Which is almost what I want, but has not dealt with the possibility of non-= > complex numbers in the list. Is there a compact way of doing this, such wit= > h a list of rules? Nothing obvious seems to work, the only success I have h= > ad is splitting the list into real and complex sublists, applying rules to = > each list individually and then recombining them, which seems like an awful= > lot of hard work. > > What I want is > toPoints[{1+3i, 2, 1-3i}] == {{1,3},{2,0},{1,-3}} > > Any help appreciated, > Thanks. > > Andrew.