MathGroup Archive 2005

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

Search the Archive

Re: Validating functions input

  • To: mathgroup at smc.vnet.net
  • Subject: [mg58818] Re: [mg58784] Validating functions input
  • From: Chris Chiasson <chris.chiasson at gmail.com>
  • Date: Tue, 19 Jul 2005 04:10:45 -0400 (EDT)
  • References: <200507180721.DAA23422@smc.vnet.net>
  • Reply-to: Chris Chiasson <chris.chiasson at gmail.com>
  • Sender: owner-wri-mathgroup at wolfram.com

look up Condition in the help file

Clear[f]
f::badinput = "`1` > \!\(`2`\^2\). The first argument \
needs to be less than or equal to the square of the \
second."
f[x_, y_] /; x > y^2 := (Message[f::badinput, x, y]; )
f[1, 2]
f[2, 1]


On 7/18/05, Nilton <nilton.volpato at ig.com.br> wrote:
> 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
> 
> 


-- 
Chris Chiasson
http://chrischiasson.com/
1 (810) 265-3161




  • Prev by Date: Re: Validating functions input
  • Next by Date: Functional equations for HermiteH[n,x]
  • Previous by thread: Validating functions input
  • Next by thread: Re: Validating functions input