MathGroup Archive 2006

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

Search the Archive

Re: Using variables in packages

  • To: mathgroup at smc.vnet.net
  • Subject: [mg68096] Re: Using variables in packages
  • From: "akil" <akomur at wanadoo.nl>
  • Date: Sun, 23 Jul 2006 03:42:13 -0400 (EDT)
  • References: <e9susc$rmp$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Using Global`X did the job, had uite a few of those kinds of variables in my 
package, now it works great.

Thank you very much.

Akil

"David Park" <djmp at earthlink.net> schreef in bericht 
news:e9susc$rmp$1 at smc.vnet.net...
> Akil,
>
> If you use a new symbol in the private part of a package, then it gets the
> name packgename`Private`symbol. The solution is simple. Just use Global`X
> instead of X.
>
> However, in cases like this you would probably want to pass the variable
> name you wished to use. Your could, for example, use
>
> lijnTussenVertices[punt1_, punt2_, var_:Global`X]:= ...
>
> where the variable name would be X by default, but you could pass another
> symbol if you wished.
>
> David Park
> djmp at earthlink.net
> http://home.earthlink.net/~djmp/
>
> From: akil [mailto:akomur at wanadoo.nl]
To: mathgroup at smc.vnet.net
>
>
> I use the following two methods in teh same mathematica package:
>
> lijnTussenVertices[punt1_, punt2_] :=
>    Module[{functie, richtingsVector, hoogte, p1x, p1y, p2x, p2y},
>       p1x = punt1[[1]]; p1y = punt1[[2]];
>       p2x = punt2[[1]]; p2y = punt2[[2]];
>       richtingsVector = (p2y - p1y)/(p2x - p1x);
>       hoogte = (p1x*richtingsVector) - p1y;
>       functie = richtingsVector*X - hoogte;
>       If[p1x == p2x, p1x, functie]
> ];
>
> edgesPartFuncties[part_,aantalVertices_] := Module[{edgeFunctie,i},
>      edgeFunctie = {};
>      For[i = 1, i < aantalVertices,
> i++,AppendTo[edgeFunctie,lijnTussenVertices[part[[i]], part[[i + 1]]]]];
>      AppendTo[edgeFunctie, lijnTussenVertices[part[[aantalVertices]],
> part[[1]]]];
>      Return[edgeFunctie]
> ];
>
> When I call edgesPartFuncties[part,aantalVertices] on a part with a 
> certain
> number of vertices I always get something like:
>
> {\!\(\(-40\) + 2\ Global`Private`X, 200\/3 - \(2\ Global`Private`X\)\/3, 
> \)}
>
> How Can i fix this so I get X instead of Global`Private`X?
>
> Akil
>
>
> 



  • Prev by Date: Re: FindRoot::nlnum error
  • Next by Date: Need pure function to opeate on integer lists
  • Previous by thread: RE: Using variables in packages
  • Next by thread: Re: Quaternion problem--> quantum differeentials