/* convert a decimal integer to a list of digits in base `base' */ dec2digits(d, base):= block([digits: []], while (d>0) do block([newdi: mod(d, base)], digits: cons(newdi, digits), d: round( (d - newdi) / base)), digits)$ dec2digits(123, 10); /* [1, 2, 3] */ dec2digits( 8, 2); /* [1, 0, 0, 0] */