MathGroup Archive 2010

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

Search the Archive

Re: elementary questio about packages

  • To: mathgroup at smc.vnet.net
  • Subject: [mg108254] Re: [mg108238] elementary questio about packages
  • From: "David Park" <djmpark at comcast.net>
  • Date: Fri, 12 Mar 2010 07:07:25 -0500 (EST)
  • References: <24440876.1268308256232.JavaMail.root@n11>

This is a not uncommon situation where the package routine does not behave
as the notebook routine.

The best solution may be to supply the desired symbol names to the package
routine.

MyOptimize[parms, {z1,z2,z3}]

We assume that these appear in the parms expressions. This first method is
more general and also picks up the Context of the notebook calling the
routine (such as Help Function pages).

A second method (but much more restricted for the user) is to put the
relevant package code inside a With statement:

With[{z1=Global`z1, z2=Global`z2, z3=Global`z3},...]

A third method is to use a default argument:

MyOptimize[parms_, vars_List:{Global`z1,Global`z2,Global`z3}] 


David Park
djmpark at comcast.net
http://home.comcast.net/~djmpark/  


From: Francisco Gutierrez [mailto:fgutiers2002 at yahoo.com] 

Dear List:
I made a package with a function that has a minimization. The minimization 
returns, as should be, the value of the optimization, and then the values
 of the variables, in the form {z1->10,z2->20,z3->50}.
 
In the notebook, this works perfectly well. In the package, however, the
function throws back the variables in the form
{contextname`z1->10,contextname`z2->20}.
This is obnoxious, and makes the result much harder to utilize. How can I
avoid this? I tried deleting 
Begin["`Private`"], but then  I got a completely crazy result.
What should I do?
Fg




  • Prev by Date: Re: bad Mathieu functions
  • Next by Date: Re: plot solution derivative
  • Previous by thread: Re: Re: elementary questio about packages
  • Next by thread: Re: elementary questio about packages