MathGroup Archive 2001

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

Search the Archive

Re: Question involving scope/recursion/arguments

  • To: mathgroup at smc.vnet.net
  • Subject: [mg27731] Re: Question involving scope/recursion/arguments
  • From: "John Eric Hanson" <jhanson1 at stny.rr.com>
  • Date: Tue, 13 Mar 2001 03:52:48 -0500 (EST)
  • Sender: owner-wri-mathgroup at wolfram.com

Paul-

One common example of what I'm trying to do is the quicksort algorithm -
where a list or an array is sorted in place recursively.  I am finding greta
frustration trying to find the Mathematica technique which would result in
behavior similar to passing an argument by reference or a pointer to an
argument.

I can do this with a global variable, but then, as far as I can see, I'm
bound to passing in an argument with the same name as the global variable
I'm using (else I have to make a copy of the variable unless Mathematica
will allow two variables to reference the same data in memory - I'm
obviously reasonably new to Mathematica).

Thanks again,

Eric


> Well, you don't specify what you want to do, so I can only offer this
> generic advice:
>
> f[list_,a_,b_] := (g[list], If[r, list = f[list_,c,d], STOP])
>
> Or you can make the list global, not a passed argument.
>
> --
> Paul Lutus
> www.arachnoid.com
>
>
>
>



  • Prev by Date: matrix diffential equations follow up
  • Next by Date: Re: How to calculate the area of a polygon?
  • Previous by thread: Re: Question involving scope/recursion/arguments
  • Next by thread: Re: Re: Question involving scope/recursion/arguments