Services & Resources / Wolfram Forums / MathGroup Archive

MathGroup Archive 2010

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

Search the Archive

Re: Unevaluated functions

  • To: mathgroup at
  • Subject: [mg109383] Re: Unevaluated functions
  • From: David Bailey <dave at>
  • Date: Sat, 24 Apr 2010 04:02:23 -0400 (EDT)
  • References: <hqou0u$9g5$> <hqp995$gqv$> <hqrja6$lvv$>

mokambo wrote:

> Following your suggestions I tried:
> PowerMod[___] := "N/A";
> but it does not work unless you unprotect the symbol (a bad idea)
> Attributes[PowerMod]
> = {Listable, Protected, ReadProtected}
> So I searched through the docs and found:
> Check[PowerMod[3, -1, 288], "N/A"]

If you really want this effect, why not use Unprotect - you can always 
use Protect after you have made the change! (Note that these changes 
only affect the in-core copy of the function - no permanent change is made!)

Check is all very well, but some functions - such as Integrate - can 
return unevaluated without giving a message. I would supply your own 
function that calls the real function internally, for example:

In[498]:= MyIntegrate[x__] := Module[{ans},
    ans = Integrate[x];
    If[Head[ans] === Integrate,

In[499]:= MyIntegrate[f[x], x]

Out[499]= "N/A"

In[500]:= MyIntegrate[Sin[x], x]

Out[500]= -Cos[x]

David Bailey

  • Prev by Date: Re: Experimental`NumericalFunction::dimsl
  • Next by Date: Re: Speed Up Routines
  • Previous by thread: Re: Unevaluated functions
  • Next by thread: Find (cyclic) Sequence