MathGroup Archive 2006

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

Search the Archive

RE: Using variables in packages

  • To: mathgroup at smc.vnet.net
  • Subject: [mg68093] RE: [mg68059] Using variables in packages
  • From: "David Park" <djmp at earthlink.net>
  • Date: Sat, 22 Jul 2006 06:24:16 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

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: Programming with options.
  • Next by Date: Re: Reconciling BinCounts and RangeCounts
  • Previous by thread: Using variables in packages
  • Next by thread: Re: Using variables in packages