MathGroup Archive 1999

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

Search the Archive

Re: List manipulation question

  • To: mathgroup at smc.vnet.net
  • Subject: [mg15928] Re: List manipulation question
  • From: Jens-Peer Kuska <kuska at informatik.uni-leipzig.de>
  • Date: Wed, 17 Feb 1999 23:33:59 -0500
  • Organization: Universitaet Leipzig
  • References: <7a2b7v$1t6@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Maarten.vanderBurgt at icos.be wrote:
> 
Hi Maarten,

you must give Swap23[] the attribute HoldAll to prevent the evaluation. 

SetAttributes[Swap23, HoldAll]

Swap23[l_Symbol] := 
  Module[{tmp}, tmp = l[[2]]; l[[2]] = l[[3]]; l[[3]] = tmp;]


will change the second and third entry in l. You can but you don't
need return a value because the parts of l get assigned.

Hope that helps
  Jens 

> Dear all,
> 
> In the following piece of code I define a function Swap23 which is ment
> to swap elements 2 and 3 in a list.
> Executing the function on a simple list I get an error. Why do I get
> this error? Why do I not get this error when I execute the commnad from
> Swap23 "by hand" as is shown in In[4]?
> 
> Thanks for any help
> 
> Maarten van der Burgt
> Icos Vision Systems
> Leuven
> Belgium


  • Prev by Date: Re: Fourier and FFT: Powers of 2 only?
  • Next by Date: Re: escape-sequences in strings
  • Previous by thread: Re: List manipulation question
  • Next by thread: Re: List manipulation question