Re: Validating functions input

*To*: mathgroup at smc.vnet.net*Subject*: [mg58819] Re: Validating functions input*From*: "Drago Ganic" <drago.ganic at in2.hr>*Date*: Tue, 19 Jul 2005 04:10:50 -0400 (EDT)*References*: <dbflkk$n0p$1@smc.vnet.net>*Sender*: owner-wri-mathgroup at wolfram.com

Nilton, If you want the result to be unaveluated, you have to say so. Use: f[x_,y_] := If[ x <= 2^y, Hold[ f[x,y] ], Message[f::invalid] ] or f[x_,y_] := If[ x <= 2^y, HoldForm[ f[x,y] ], Message[ f::invalid ] ] Greetings from Croatia, Drago "Nilton" <nilton.volpato at ig.com.br> wrote in message news:dbflkk$n0p$1 at smc.vnet.net... >I have a function that must have its input validated. > > f[x,y] > > I want to validate if x <= 2^y. If it's valid, then just return the > symbol f[x,y] unevaluated. If it's not valid, I want to return some > symbol, Null for instance, and issue an error message. > > The following is a try, but it doesn't work, because it's definition is > recursive: > > f::invalid = "Invalid arguments" > f[x_,y_] := If[x <= 2^y, f[x,y], Message[f::invalid]] > > Is there any way to implement this? > > Thanks, > -- Nilton >