This comment is reply for 1792 nobsun: 昔のコード、漢数字名があるかぎり表示可能...(整数の漢数字表記). Go to thread root.
shiro #1803(2007/08/03 19:53 GMT) [ Scheme ] Rating1/1=1.00
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
(use text.tree) (define (漢数字 整数) (define 桁 '("" "" "弐" "参" "四" "伍" "六" "七" "八" "九")) (define 小位列 '("千" "百" "拾" "")) (define 大位列 '("" "万" "億" "兆" "京" "垓" "(禾予)" "穰" "溝" "澗" "正" "載" "極")) (define 特位列 '("恒河砂" "阿僧祇" "那由多" "不可思議" "無量大数")) (define 壱恒河砂 (expt 10 52)) (define 限界 (expt 10 92)) (define (小再帰 数 単位 位列) (cond ((zero? 数) '()) ((= 数 1) '("壱")) ((>= 数 単位) `(,(list-ref 桁 (quotient 数 単位)) ,(car 位列) ,@(小再帰 (modulo 数 単位) (/ 単位 10) (cdr 位列)))) (else (小再帰 数 (/ 単位 10) (cdr 位列))))) (define (大再帰 数 位列) `(,@(if (>= 数 10000) (大再帰 (quotient 数 10000) (cdr 位列)) '()) ,@(if (zero? (modulo 数 10000)) '() `(,(小再帰 (modulo 数 10000) 1000 小位列) ,(car 位列))))) (define (特大再帰 数 位列) `(,@(if (>= 数 100000000) (特大再帰 (quotient 数 100000000) (cdr 位列)) '()) ,@(if (zero? (modulo 数 100000000)) '() `(,(大再帰 (modulo 数 100000000) 大位列) ,(car 位列))))) (tree->string (cond ((>= 整数 限界) "限界突破") ((>= 整数 壱恒河砂) (list (特大再帰 (quotient 整数 壱恒河砂) 特位列) (大再帰 (modulo 整数 壱恒河砂) 大位列))) (else (大再帰 整数 大位列)))) )
Rating1/1=1.00-0+
[ reply ]
shiro
#1803()
[
Scheme
]
Rating1/1=1.00
Rating1/1=1.00-0+