From: David Bailey on 24 Apr 2010 03:59 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, "N/A", ans ] ]; In[499]:= MyIntegrate[f[x], x] Out[499]= "N/A" In[500]:= MyIntegrate[Sin[x], x] Out[500]= -Cos[x] David Bailey http://www.dbaileyconsultancy.co.uk
First
|
Prev
|
Pages: 1 2 Prev: Find (cyclic) Sequence Next: Download as Live Mathematica from Wolfram|Alpha |