RE: Re: Functions inside list
- To: mathgroup at smc.vnet.net
- Subject: [mg70521] RE: [mg70461] Re: Functions inside list
- From: "David Annetts" <davidannetts at aapt.net.au>
- Date: Wed, 18 Oct 2006 04:18:10 -0400 (EDT)
Hi Akil, > In package.m I do now: > maxWidthInternal[beta_?NumericQ]:=berekenMaxWidth[beta,linkerO VCone,cy,dy,centerOfMassx,centerOfMassy,rcAB,ax,ay,rcCD,cx,dx,rcCD,RightVBi, boundVab,bx,by,partList[[sp]],vdomein]; > > where all values except beta are known as can be seen in the > package they are used. berekenMaxWidth is a module defined in > the same package as maxWidthInternal is called. > maxWidthInternal is called by anoter Module in the same package. > > This solves my problems inside the package they are used, but > now I get problems later on. The list contains > {{x1,x2},Global`Private`maxWidthInternal[Global`Private`beta]} > now, but as many can see when I search for intersections > later on, or when I try to Plot it later using the list in > another package for instance, I only have the reference > "Global`Private`maxWidthInternal[Global`Private`beta]" but > this does not know all the other variables seen above. These > variables change for each time maxWidthInternal is called. > > Is there any way I can give it those values along so that it > will work in other packages later on? I'm not sure I understand the question .... It's possible to give your function a set of default arguments that may be optionally omitted so that ftn[x_, y_:10, z_:30] may be called as ftn[x], which equates to ftn[x, 20, 30] or ftn[x, 60, 70]. You can accomplish a similar effect using optional arguments. This may be advantageous since you can set global options, then check their value in various functions in your package, eg,. SetOptions[pkgOpts, a -> 10, b, -> 20]; ftnA[x_, opts___] := Module[ {}, internalA = a /. {pkgOpts} /. {opts} /. Options[pkgOpts]; (* remainder of function *) ]; The second form is preferable since there's only one version of the function rather than several, each with different numbers of arguments. But as I said, I'm not sure I understand the question. Regards, Dave.