How to prevent evaluation.



What are you trying to do and why are you using %if rather than if?

These days, regular 'if' returns an expression if the condition cannot be
evaluated, e.g.

(%i2) if a>0 then 1 else 0;
(%o2)                        if a > 0 then 1 else 0

            -s

On Sun, Dec 27, 2009 at 5:16 PM, Richard Hennessy <rich.hennessy at verizon.net
> wrote:

>  I tried this to see the timing information.
>
> load(pw)$
>
> (%i3) showtime:true;
> Evaluation took 0.0000 seconds (0.0000 elapsed)
> (out3)
> (%i4) for i : 1 thru 2000 do %if(i>0, expand((x-y)^100),
> expand((x-y)^100));
> Evaluation took 13.0200 seconds (13.0200 elapsed)
> (out4) done...
>
> It seems like in the %if function both the then part and the else part are
> always expanded even when only one needs to be evaluated.  Is there a way to
> stop evaluation of both parts?  This would make possible major speed
> improvements dealing with large expressions.
>
>