Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2005
*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 2005

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

Search the Archive

Re: How to reverse sign on the y's in a list of (x, y)'s?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg61276] Re: [mg61231] How to reverse sign on the y's in a list of (x, y)'s?
  • From: Murray Eisenberg <murray at math.umass.edu>
  • Date: Fri, 14 Oct 2005 05:54:37 -0400 (EDT)
  • Organization: Mathematics & Statistics, Univ. of Mass./Amherst
  • References: <200510130539.BAA04564@smc.vnet.net>
  • Reply-to: murray at math.umass.edu
  • Sender: owner-wri-mathgroup at wolfram.com

Here's one way, including an example to generate the pairs:

   pairs = Partition[Table[Random[Integer, {-49, 50}], {6}], 2]
{{-43, -26}, {-22, 16}, {17, -44}}

   pairs /. {x_?NumericQ, y_?NumericQ} -> {x, -y}
{{-43, 26}, {-22, -16}, {17, 44}}

The "?NumericQ" is used in order to avoid a spurious result in the case 
that you have a list of exactly two pairs.


sherifffruitfly at gmail.com wrote:
> Hi all,
> 
> This is really dumb, but I just don't know how to do it...
> 
> Import from excel gives me a list of ordered pairs, and I want the 2nd
> element of each pair to be of opposite sign. Sticking the negative sign
> in front of the entire Import statement reverses both the 1st and the
> 2nd elements (duh). How do I get just the second item to reverse sign?
> 
> thanks!
> 
> 

-- 
Murray Eisenberg                     murray at math.umass.edu
Mathematics & Statistics Dept.
Lederle Graduate Research Tower      phone 413 549-1020 (H)
University of Massachusetts                413 545-2859 (W)
710 North Pleasant Street            fax   413 545-1801
Amherst, MA 01003-9305


  • Prev by Date: Re: big integer for Range
  • Next by Date: Re: How to reverse sign on the y's in a list of (x, y)'s?
  • Previous by thread: Re: How to reverse sign on the y's in a list of (x, y)'s?
  • Next by thread: Re: How to reverse sign on the y's in a list of (x, y)'s?