RosettaCodeData/Task/Van-der-Corput-sequence/Maxima/van-der-corput-sequence-1.maxima

12 lines
313 B
Text
Raw Permalink Normal View History

2014-01-17 05:32:22 +00:00
/* 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] */