Maxima interface to Lisp bit-functions



Hello,

I frequently make use of bit-functions in some of my IT-classes where I use Maxima as 
programming language. I want to get rid of the question marks, so I asked Robert if I can 
put a Maxima interface to these Lisp functions somewhere in share/contrib. Robert wants to 
see them in src and asked me to describe the new functions to the list.

Comments are welcome.

lsh(int, count): left shift
lsh(int):  count=1 by default
rsh(int, count): right shift
rsh(int):  count=1 by default

logbitp(index, integer):  tests, if bit with weight 2^index is 1

logand(int1, int2, ... ):	bitwise and
logxor(int1, int2, ... ):	bitwise xor
logior(int1, int2, ... ):	bitwise ior
logeqv(int1, int2, ... ):	bitwise equivalence

lognot(int):  bitwise not

integer_length(int):  length of the bit representation

All function behave as follows:

if all args are integers => evaluation
if at least one arg is a string, a Maxima list or constant but not an integer => merror
all other cases => unevaluated expression

in addition: logbitp errors, if index is negativ

example session:

(%i2) lsh(7);
(%o2)                                 14
(%i3) lsh(7,3);
(%o3)                                 56
(%i4) lsh(7,-1);
(%o4)                                  3
(%i5) lsh(3*n,3);
(%o5)                             lsh(3 n, 3)
(%i6) %,n=5;
(%o6)                                 120
(%i7) lsh([1,2,3],3);
bad first argument to `lsh': [1,2,3]
 -- an error.  To debug this try debugmode(true);


Volker van Nek