MathGroup Archive 1996

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

Search the Archive

Re: Re; Reordering lists?!


Andre and Alain wrote:
> 
>         Hey! I have a list of Numbers, 1 to 4, and wish to rescale them so
> that 1 replkaces 4 and 3 replaces 2 and 2 replaces 3 etc. I made a little
> code to do this on an element per element basis and it doesn't seem to do
> it! Could someone let me know what I'm doing wrong or whether it's a Mma
> problem? Thanks
> 
>...DELETIA...

Try this:

a={2, 1, 1, 1, 1, 2, 1, 2, 1, 1, 1, 2, 2, 1, 1, 3, 1, 1, 2, 1, 2, 1, 2, 1, 1,
1, 1, 2, 1, 2, 1, 3, 1,
  2, 2, 1, 2, 1, 2, 3, 2, 4, 1, 1, 1, 1, 2, 1, 1, 1, 1, 2, 2, 2, 1, 2, 1, 2,
3, 2, 2, 2, 1, 2, 1,
  2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 2, 2, 2, 1}

Map[Mod[#, 4] + 1&, a]

-- 
Dr Stephen P Luttrell                  luttrell at signal.dra.hmg.gb
Adaptive Systems Theory                01684-894046 (phone)
Room EX21, Defence Research Agency     01684-894384 (fax)           
Malvern, Worcs, WR14 3PS, U.K.         http://www.dra.hmg.gb/cis5pip/Welcome.html

==== [MESSAGE SEPARATOR] ====


  • Prev by Date: Re: How do I use Select[list,condition]?
  • Next by Date: Re: Reordering lists?!
  • Previous by thread: Re: Re; Reordering lists?!
  • Next by thread: Re: Re; Reordering lists?!