Here I compile two functions
(the source is given below)
(%i2) compile(integerdigits,fromdigits);
Warning-> block is an undefined global variable.
Warning-> m is an undefined global variable.
Warning-> diff is an undefined global variable.
Warning-> b is an undefined global variable.
Warning-> r is an undefined global variable.
Warning-> pad is an undefined global variable.
Warning-> i is an undefined global variable.
Warning-> s is an undefined global variable.
I wonder why these warnings appear ?
The functions still seem to work, but I haven't
tested them thoroughly.
------code
/*
integerdigit(n) returns list of digits in integer n
integerdigits(n,b) returned digits are in base b
integerdigits(n,b,pad) leading zeros appended so list
is of total length pad.
for base greater than 10, additional digits are denoted in decimal,
not using A,B, etc.
*/
integerdigits(n,[ib]) := (block[m,r:[],b:10,pad:0,diff],
n : abs(n),
if length(ib)>0 then b:ib[1],
if length(ib)>1 then pad:ib[2],
while n > 0 do (
m : floor(n/b),
r:cons( n-m*b, r),
n:m),
diff : pad-length(r),
if diff > 0 then r:append(create_list(0,i,1,diff),r),
r);
/* fromdigits(v) return integer computed from list of digits v
fromdigits(v,b) digits are interpreted base b
*/
fromdigits(v,[ib]) := (block[s:0,b:10,i,m],
if length(ib)>0 then b:ib[1],
m:length(v),
for i thru m do
s : s + v[m-i+1]*b^(i-1),
s);