MathGroup Archive 2003

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

Search the Archive

Re: Mathematica Problem

  • To: mathgroup at smc.vnet.net
  • Subject: [mg42099] Re: Mathematica Problem
  • From: Jens-Peer Kuska <kuska at informatik.uni-leipzig.de>
  • Date: Thu, 19 Jun 2003 03:59:07 -0400 (EDT)
  • Organization: Universitaet Leipzig
  • References: <bcp0ve$7t1$1@smc.vnet.net>
  • Reply-to: kuska at informatik.uni-leipzig.de
  • Sender: owner-wri-mathgroup at wolfram.com

Hi,

in your package the symbols a and b in
Thread[{a,b}->{1,2}] 

are in the context MathIA`Test`Private`,

when myTest[] is called ToExpression["a!=b"] evaluates
in the global context and the symbols a and b are
not identical with a and b from the MathIA`Test`Private`a, and
MathIA`Test`Private`b .

To fix it you have to write

BeginPackage["MathIA`Test`"]

myTest::usage = " getRandomSet [ ] This is test package ";

Begin["`Private`"]
myTest[] := 
  Module[{temp2}, 
    temp2 = ToExpression["MathIA`Test`Private`a!=MathIA`Test`Private`b
"] /. 
        Thread[{a, b} -> {1, 2}];
Print[temp2];
]

End[]

EndPackage[]

Regards
  Jens

Jai Bharat Patel wrote:
> 
> Hi,
> 
> Following statement is working when use it directly in
> Mathematica:
> 
> In[1]:= ToExpression["a!=b"] /. Thread[{a,b}->{1,2}]
> 
> Out[1]=True
> 
> But  same statement is not working if I use it from a
> package:
> 
> Package:
> 
> BeginPackage["MathIA`Test`"]
> 
> myTest::usage =
> " getRandomSet [ ] This is test package ";
> 
> Begin["`Private`"]
> myTest[ ] :=
> Module[ { temp2 },
>     temp2 = ToExpression["a!=b"]) /.
> Thread[{a,b}->{1,2}] ;
>     Print[temp2];
> ]
> 
> End[]
> 
> EndPackage[]
> 
> output:
> 
> In[3]:= <<MathIA`Test`
> 
> In[4]:= myTest[]
> a != b
> 
> Please let me know where is my mistake.
> 
> TIA
> 
> __________________________________
> Do you Yahoo!?
> SBC Yahoo! DSL - Now only $29.95 per month!
> http://sbc.yahoo.com


  • Prev by Date: WSEAS NEWSLETTER in Applied Mathematics (Malta 2001)
  • Next by Date: better version of Maxwell to Helmholtz
  • Previous by thread: Mathematica Problem
  • Next by thread: Re: Mathematica Problem