MathGroup Archive 1995

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

Search the Archive

A simple swap function

  • To: mathgroup at smc.vnet.net
  • Subject: [mg2132] A simple swap function
  • From: valentin at wam.umd.edu (William F. Campbell)
  • Date: Wed, 4 Oct 1995 01:56:17 -0400
  • Organization: University of Maryland, College Park

  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