RosettaCodeData/Task/Van-der-Corput-sequence/Maxima/van-der-corput-sequence-2.m...

10 lines
246 B
Plaintext

/* convert a list of digits in base `base' to a decimal integer */
digits2dec(l, base):= block([s: 0, po: 1],
for di in reverse(l) do (s: di*po + s, po: po*base),
s)$
digits2dec([1, 2, 3], 10);
/* 123 */
digits2dec([1, 0, 0, 0], 2);
/* 8 */