Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
|
|
@ -0,0 +1,11 @@
|
|||
/* 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] */
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
/* 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 */
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
vdc(n, base):= makelist(
|
||||
digits2dec(
|
||||
dec2digits(k, base),
|
||||
1/base) / base,
|
||||
k, n);
|
||||
|
||||
vdc(10, 2);
|
||||
/*
|
||||
1 1 3 1 5 3 7 1 9 5
|
||||
(%o123) [-, -, -, -, -, -, -, --, --, --]
|
||||
2 4 4 8 8 8 8 16 16 16
|
||||
*/
|
||||
|
||||
vdc(10, 5);
|
||||
/*
|
||||
1 2 3 4 1 6 11 16 21 2
|
||||
(%o124) [-, -, -, -, --, --, --, --, --, --]
|
||||
5 5 5 5 25 25 25 25 25 25
|
||||
*/
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
/* 11 in decimal is */
|
||||
digits: digits2dec([box(1), box(0), box(1), box(1)], box(2));
|
||||
aux: expand(digits2dec(digits, 1/base) / base)$
|
||||
simp: false$
|
||||
/* reflected this would become ... */
|
||||
subst(box(2), base, aux);
|
||||
simp: true$
|
||||
|
||||
/*
|
||||
|
||||
3 2
|
||||
""" """ """ """ """ """ """
|
||||
(%o126) "2" "1" + "2" "0" + "2" "1" + "1"
|
||||
""" """ """ """ """ """ """
|
||||
|
||||
- 4 - 3 - 2 - 1
|
||||
""" """ """ """ """ """ """ """
|
||||
(%o129) "1" "2" + "0" "2" + "1" "2" + "1" "2"
|
||||
""" """ """ """ """ """ """ """
|
||||
|
||||
*/
|
||||
Loading…
Add table
Add a link
Reference in a new issue