Re: getting module output in replace form
- To: mathgroup at smc.vnet.net
- Subject: [mg24648] Re: getting module output in replace form
- From: "Allan Hayes" <hay at haystack.demon.co.uk>
- Date: Mon, 31 Jul 2000 09:23:19 -0400 (EDT)
- References: <8lsts5$22u@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Mike, Please look at the InputForm of your output. It looks as if it will contain expressions like 0.234*"var1->", not rules. How about the following? CalculateVariables[a_, b_, c_] := Thread[Rule[{var1, var2, var3}, {a b^c, b/c, a - b}]] CalculateVariables[x, y, z] {var1 -> x*y^z, var2 -> y/z, var3 -> x - y} Allan --------------------- Allan Hayes Mathematica Training and Consulting Leicester UK www.haystack.demon.co.uk hay at haystack.demon.co.uk Voice: +44 (0)116 271 4198 Fax: +44 (0)870 164 0565 "Michael Gilchrist" <mag5 at duke.edu> wrote in message news:8lsts5$22u at smc.vnet.net... > Hi, > > I am trying to create a module that will output a list of replacement > rules. > > for example > > {var1, var2}/.CalculateVariables[1, 0.3, 1.222] > > where CalculateVariables is the module I am writing. > > i.e. > > CalculateVariables[a_, b_, c_]:= > Module[{var1, var2, var3, var4}, > > var1 = a* b^c; > var2 = b/c; > . > . > . > > {"var1 ->" OutputForm[var1], > "var2 ->" OutputForm[var2], > "var3 ->" OutputForm[var3], > "var4 ->" OutputForm[var4] > } > ] > > But if I try to use the output as a replacement rule I get > > >ReplaceAll::"reps" {{var1-> 0.234, var2->0.323, var3-> 100001, var4->0}} > is neither a list of replacement > rules nor a valid dispatch table, and so cannot be used for replacing." > > > > I have tried wrapping the "vari ->" in textform, outputform, etc but get > nowhere. > > I feel like I must be doing something wrong since this seems like it > should be an easy and common use of a module. Any help would be > appreciated. > > Thanks, > > > Mike > > > Michael Gilchrist > Dept. of Biology > Duke University > Durham, NC 27708 > > > >