Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2006
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2006

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

Search the Archive

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.
		


  • Prev by Date: Re: RE: How to make an inline cell (inside a Text cell) to be a centered equation?
  • Next by Date: Re: save value in array during loop
  • Previous by thread: Re: Functions inside list
  • Next by thread: RE: Re: Functions inside list