Maxima interface to Lisp bit-functions



On Wed, Mar 19, 2008 at 5:39 PM, van Nek <van.nek at arcor.de> wrote:
> bit_and(x) => x
> bit_and(foo(y)) => foo(y)
> bit_and(x, -x-1) => 0
> Should these be valid for all x and foo,
> or do they require that x is declared as integer and foo is declared as
> integervalued?

As a general rule, Maxima is extremely loose in typechecking. Not only
does it simplify 0*x => 0, but even 0/x => 0 and "."(x) => x

So I think the above simplifications are fine.

> (%i1) declare(x,even);
> (%o1)                                done
> (%i2) featurep(x,even);
> (%o2)                                true
> (%i3) evenp(x);
> (%o3)                                false

This is confusing, I agree.  evenp checks for even *literal numbers*:

     evenp(floor(x)*2) => false

and featurep has been extended not only to look for features
explicitly added to objects, but for the property in general:

    featurep(floor(x)*2,even) => true

This is really not sensible, but that's the way it is for now.

                 -s