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: [mg27654] Re: Question involving scope/recursion/arguments
  • From: Jens-Peer Kuska <kuska at informatik.uni-leipzig.de>
  • Date: Sat, 10 Mar 2001 00:49:43 -0500 (EST)
  • Organization: Universitaet Leipzig
  • References: <98a224$cri@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Hi,

a) you can only prevent the copy of an argument
   if the function hold the argument, otherwise
   Mathematica create always a copy of the 
   arguments
b) you can make a local function that use the list

   faux[list_,a_,b_]:=Module[{f},
                        f[c_,d_]:=(g[list];If[r,f[c,d],STOP]);
                        f[a,b]
                       ]
 
c) you can make a block with it's dynamical name space

   f[c_,d_]:=(g[myListArgument];If[r,f[c,d],STOP]);

   faux[lst_,a_,b_]:=Block[{myListArgument=lst},
                        f[a,b]
                       ]
d) you can yuse Catch[]/Throw[] to terminate the recursion.

Regards
  Jens

John Eric Hanson wrote:
> 
> Hello all-
> 
> Having a bit of difficulty here.  In general terms, the problem is this:
> 
> I would like to have a function f that takes a list (among other things) as
> an argument.  I would then like to make some adjustments to the list and
> then call f again (from inside the first f), and so on until the list
> satisfies a certain criteria.  The general template would look something
> like this:
> 
> f[list_,a_,b_] := (g[list], If[r, f[list_,c,d], STOP])
> 
> I can accomplish my intended task using a global variable for list (or
> assigning list to a global), but I haven't succeded yet to maintain the
> values when I simply want to recursively make adjustments to list without
> introducing a copy of it (or fixing the function to a specific variable).
> 
> Any hints would be appreciated.
> 
> Thanks much,
> 
> Eric


  • Prev by Date: Re: help create a unique solution system
  • Next by Date: RE: Letting integers be integers (when using //N)
  • Previous by thread: Re: Question involving scope/recursion/arguments
  • Next by thread: Re: Question involving scope/recursion/arguments