Re: getting module output in replace form
- To: mathgroup at smc.vnet.net
- Subject: [mg24664] Re: [mg24605] getting module output in replace form
- From: BobHanlon at aol.com
- Date: Mon, 31 Jul 2000 09:23:31 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
In a message dated 7/28/2000 6:05:51 PM, mag5 at duke.edu writes:
>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.
>
CalculateVariables[a_, b_, c_] :=
Module[{v1, v2, v3, v4},
v1 = a* b^c;
v2 = b/c;
v3 = 3;
v4 = 4;
{var1 -> v1, var2 -> v2, var3 -> v3, var4 -> v4}]
Bob Hanlon