MathGroup Archive 1995

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

Search the Archive

Re: Programming

  • To: mathgroup at smc.vnet.net
  • Subject: [mg2839] Re: [mg2819] Programming
  • From: Richard Mercer <richard at seuss.math.wright.edu>
  • Date: Sat, 23 Dec 1995 03:19:48 -0500

Jack,

Here is some code that will do what I think you want.
The first step is to create a command that checks for error messages  
and undesirable outcomes. I'll call it IntegrateG.
The two Print commands are there just to take up space where your code  
will go. If you don't care about error messages, you don't need the  
Check command, just use res = Integrate[items].

IntegrateG[items__]:=
  Module[{res},
    res = 

      Check[
        Integrate[items],
        (* error-handling code *)
        Print["Error"]
      ];
    If[Head[res] === Integrate,
      (* your code here *)
      Print["Failure"];
      res,
      res
    ]
  ];

This will work fine. But suppose you want it to automatically replace  
Integrate? Here's how:

$Pre = (# /. Integrate->IntegrateG)&;

Now give it a try:
In[5]:=
Integrate[Sqrt[BesselJ[0,x]],x]

Failure
Out[5]=
Integrate[Sqrt[BesselJ[0, x]], x]

Richard Mercer


  • Prev by Date: Polar Contour Plots
  • Next by Date: Re: Programming
  • Previous by thread: Re: Programming
  • Next by thread: Re: Programming