Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2012

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

Search the Archive

Re: How to swap two elements of a list

  • To: mathgroup at smc.vnet.net
  • Subject: [mg127590] Re: How to swap two elements of a list
  • From: Diana Mecum <diana.mecum at gmail.com>
  • Date: Sun, 5 Aug 2012 14:58:54 -0400 (EDT)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • Delivered-to: l-mathgroup@wolfram.com
  • Delivered-to: mathgroup-newout@smc.vnet.net
  • Delivered-to: mathgroup-newsend@smc.vnet.net
  • References: <jvklja$643$1@smc.vnet.net>

***,

Thank you for getting back to me. I had a little difficulty describing what I was trying to do.

I start with a list which begins as follows:

{2,3,4,5,7,8,9,11,13,16,17,19,23,25,27,29,31

Now, I want to swap the 2 with the 4, the 3 with the 8, the 5 with the 9. "2" is the first element of SWAP LIST 1. "4", which I want to swap with "2" is the first element of SWAP LIST 2. "3" is the second element of SWAP LIST 1. "8", which I want to swap with "3" is the second element of SWAP LIST 2. And, so on.

The resulting list is

{4,8,2,9,16,3,5,25,27,7,32,49,64,11,13,81,121

Hope this is more clear.

Diana



  • Prev by Date: Re: How to Extract Conditional Expression?
  • Next by Date: Re: Problem finding maximum
  • Previous by thread: Re: How to swap two elements of a list
  • Next by thread: Re: How to swap two elements of a list