MathGroup Archive 1995

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

Search the Archive

Confused about contexts ...

  • To: mathgroup at christensen.cybernetics.net
  • Subject: [mg523] Confused about contexts ...
  • From: Paul E Howland <PEHOWLAND at taz.dra.hmg.gb>
  • Date: Wed, 8 Mar 1995 15:40:34 +0200 (IST)

Dear Mathgroup,

I think I'm getting my contexts in a muddle.  Can you help me with the
following please?

Consider the following simple package:

	BeginPackage["Example`"]
	test::usage = "Test function"
	Begin["`Private`"]
		test[a_] := Module[{}, z=Sin[x];Function[x,z]]
	End[]
	EndPackage[]

I'm trying to code a function "test" that returns a function as its argument.
Thus, _what_I'd_like_to_happen_ is this:

	In[1] := 
		<<Package.m
	In[2] := 
		f = test[a]
	Out[2] :=
		Function[x,Sin[x]]
	In[3] := 
		f[theta]	
	Out[3] := 
		Sin[theta]

However, what actually happens is this:

	In[1] := 
		<<Package.m
	In[2] := 
		f = test[a]
	Out[2] :=
		Function[Example`Private`x, Example`Private`z]
	In[3] := 
		f[theta]
	Out[3] :=
		Sin[Example`Private`x]
	
Of course, in reality my function is much more complicated than Sin[x], 
and has to be calculated by the function "test".  "test" takes in data 
(represented by the variable "a" in the example above) in order to try to
calculate this function.

What am I doing wrong?

Many thanks,

Paul E Howland                         

Long Range Ground Radar Systems Section               tel. +44 (0)1684 895767
CSS2 Division, Room BY209                             fax. +44 (0)1684 896315
Defence Research Agency                           email: PEHOWLAND at DRA.HMG.GB 
Malvern, Worcs, WR14 3PS, UK.                      
-----------------------------------------------------------------------------



  • Prev by Date: How to identify equations
  • Next by Date: Vote NO!!!!!!!!!
  • Previous by thread: How to identify equations
  • Next by thread: Re: Confused about contexts ...