A few usage based questions

*To*: mathgroup at smc.vnet.net*Subject*: [mg61153] A few usage based questions*From*: "Matt" <anonmous69 at netscape.net>*Date*: Tue, 11 Oct 2005 03:22:27 -0400 (EDT)*Sender*: owner-wri-mathgroup at wolfram.com

Hello, any light shed on the following would be appreciated: Question 1: If I wanted to experiment with ReplaceAll and ReplaceRepeated, how would I use a variable to achieve this? e.g. I tried this: replaceType = /.; (* replaceType would also be //. for subsequent runs*) (* initialize counter *) counter = 0; resultOne = (2 a M[1] M[ 2] M[] + 3 b M[1, 3] M[2] M["s"] + Log[f[ M[1] M[1.2] M[3.4] M[M]]]) replaceType {m1_M m2_M :> (++counter; MContainer[m1, m2])} but got the following error: Syntax::sntxb : Expression cannot begin with "replaceType = /.;". More... What I was trying to achieve (for an obviously longer example) was to be able to set the type of replace I wanted to do at the beginning of the cell, then use that symbolic name inside of the actual 'code'. BTW, the sample I am attempting to modify is from page 615 of Michael Trott's "The Mathematica Guidebook for Programming". Question 2: What is the correct method to limit the types of values a function will accept? If I wanted to constrain the argument type of a function to be all reals, is this the right way? f[x_Real|x_Integer] := something The above works, but I haven't seen my attempt confirmed in any documentation. Question 3: How do I know what a function returns? (e.g. a boolean or Null or an integer, a string, etc.) Thanks much, Matt