MathGroup Archive 1995

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

Search the Archive

A simple swap function


  I think I must be missing something straightforward.  I want a function
to swap the values of 2 lists.  I defined ab={a,b}, and ba={b,a}, and
swap[v1_,v2_]:=Module[{temp=v1},v1=v2;v2=temp;], and I get an Iteration
limit exceeded error.  When I look at ab, it looks like {Hold[a],Hold[b]}
(or maybe {Hold[b],Hold[a], I don't remember), and ba looks opposite.  When
I tried to use the same function on numbers, it didn't work either.  What's
wrong with what I'm doing, and how can I do what I want to do?
______________________________________________________________________________
|                                                                            |
|                When endeavoring to explain human behaviour,                |
|                never discount the possibility of stupidity.                |
|                                                                            |
|                        Never ascribe to malfeasance                        |
|                  that which can be explained as stupidity.                 |
|                                                                            |
|  Bill Campbell                                                             |
`----------------------------------------------------------------------------'


  • Prev by Date: mathematica syntax, matrix notation
  • Next by Date: Re: X-crashing!
  • Previous by thread: Re: A simple swap function
  • Next by thread: Re: A simple swap function