MathGroup Archive 1995

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

Search the Archive

switch list elements, index from inside ??

  • To: mathgroup at smc.vnet.net
  • Subject: [mg2644] switch list elements, index from inside ??
  • From: davep at newton.umsl.edu
  • Date: Sun, 3 Dec 1995 02:53:00 -0500

Salve,

I have a problem regarding the interchanging of list elements (using the routine 
posted by Richard Mercer), when I want to index the elements from inside the 
routine.

t={1,2,3,4,5,6,7,8,9,10,11};
s[list_List]:=ReplacePart[ReplacePart[list,list[[n]],m],list[[m]],n]//.
                      {m->Random[Integer,{1,10}],n->Random[Integer,{1,10}]}
s[t]


Mma complains that the part and position specification (that's m and n) in 
ReplacePart is neither an integer nor a list of non zero integers.
Why doesn't Mma accept the (Random-) Integers ? This is probably a no brainer, 
but I just don't see it.
Thanks
Gerd






  • Prev by Date: Re; Mathematica 2.2.1 upgrade/ChemicalElements
  • Next by Date: Re: help
  • Previous by thread: switch list elements, index from inside ??
  • Next by thread: Re: switch list elements, index from inside ??