rules are just functions in Maxima that sometimes return false. Therefore
s(x):= is a rule.
actually, I think the documentation should say that apply1 applies rule_1 to
expr until it fails OR RETURNS expr UNCHANGED, which is how I used it.
The documentation should probably be changed, maybe by showing this example.
I first tried to use fullmap, which didn't do the right thing, just applied
s to the lowest level.
as for maxapplydepth, I think that I would hit it if we had J(J(J(......
very deeply ..)
RJF
> -----Original Message-----
> From: maxima-bounces at math.utexas.edu
> [mailto:maxima-bounces at math.utexas.edu] On Behalf Of andre maute
> Sent: Friday, June 27, 2008 1:09 AM
> To: maxima at math.utexas.edu
> Subject: Re: [Maxima] a simplification problem
>
> On Friday 27 June 2008, andre maute wrote:
> > On Thursday 26 June 2008, Richard Fateman wrote:
> > > Js:{};
> > > s(x):= if (not(atom (x)) and inpart(x,0)=J )then Js:union(Js,{x});
> > > apply1(t2,s)$
> > > Js;
> > >
> > > I suspect it is faster, but it is certainly shorter.
> >
> > Much faster 0.8s!
>
> I have two questions regarding the usage of apply1() above.
> The manual states
>
> --------------------------------------------------------------
> ---------
> Function: apply1 (expr, rule_1, ..., rule_n)
> Repeatedly applies rule_1 to expr until it fails, then
> repeatedly applies the
> same rule to all subexpressions of expr, left to right, until
> rule_1 has
> failed on all subexpressions. Call the result of transforming
> expr in this
> manner expr_2. Then rule_2 is applied in the same fashion
> starting at the top
> of expr_2. When rule_n fails on the final subexpression, the
> result is
> returned.
> maxapplydepth is the depth of the deepest subexpressions
> processed by apply1
> and apply2.
> --------------------------------------------------------------
> ----------
>
> So rule_1, ... rule_n need not be defined with defrule?
> Is this an abuse of maxapplydepth because the expression x is
> not transformed?
>
> Regards
> Andre
>
> P.S. And why is atom(expr) inside
> Chapter 37 (Lists) and not in Chapter 6 (Expressions)?
>
> >
> > Thanks
> > Andre
> >
> > On Thursday 26 June 2008, andre maute wrote:
> > > On Thursday 26 June 2008, andre maute wrote:
> > > > I have the following terms
> > > >
> > > >