'From Squeak 3.2 of 11 July 2002 [latest update: #4917] on 7 September 2002 at 11:38:03 pm'! Object subclass: #'漢数字桁' instanceVariableNames: '数字 配列 桁 ' classVariableNames: '' poolDictionaries: '' category: 'Goodies-漢数字'! Array variableSubclass: #'漢数字配列' instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'Goodies-漢数字'! 漢数字配列 class instanceVariableNames: ''! !Object methodsFor: 'converting' stamp: 'sumim 9/7/2002 23:03'! as漢数字配列 ^ self printString asInteger asString as漢数字配列! ! !漢数字桁 methodsFor: 'accessing' stamp: 'sumim 9/7/2002 21:21'! 桁 ^ 桁! ! !漢数字桁 methodsFor: 'accessing' stamp: 'sumim 9/7/2002 20:03'! 桁: 数値 桁 _ 数値! ! !漢数字桁 methodsFor: 'accessing' stamp: 'sumim 9/7/2002 21:21'! 数字 ^ 数字! ! !漢数字桁 methodsFor: 'accessing' stamp: 'sumim 9/7/2002 20:03'! 数字: 文字 数字 _ 文字! ! !漢数字桁 methodsFor: 'accessing' stamp: 'sumim 9/7/2002 21:21'! 配列 ^ 配列! ! !漢数字桁 methodsFor: 'accessing' stamp: 'sumim 9/7/2002 20:01'! 配列: ある配列 配列 _ ある配列! ! !漢数字桁 methodsFor: 'printing' stamp: 'sumim 9/7/2002 23:31'! asString | 文字列 十進単位 万進単位 | 文字列 _ (#(零 壱 弐 参 四 五 六 七 八 九) at: 数字 asString asInteger + 1) asString. 十進単位 _ (#(#'' 拾 百 千) at: 桁 - 1 \\ 4 + 1) asString. 万進単位 _ (#(#'' 萬 億 兆 京 垓 禾予 穣 溝 澗 正 戴 極 萬 恒河砂 萬 阿僧祇 萬 那由他 萬 不可思議 萬 無量 萬 大数 萬) at: 桁 // 4 + 1 ifAbsent: [#〓]) asString. (数字 == $0 and: [配列 size > 1]) ifTrue: [文字列 _ ''. 十進単位 _ '']. (数字 == $1 and: [桁 \\ 4 ~~ 1]) ifTrue: [文字列 _ '']. (桁 \\ 8 == 1 and: [桁 // 4 > 11]) ifTrue: [(self 単位無用: 8) ifTrue: [万進単位 _ '']] ifFalse: [(桁 \\ 4 ~~ 1 or: [self 単位無用: 4 ]) ifTrue: [万進単位 _ '']]. ^ 文字列, 十進単位, 万進単位! ! !漢数字桁 methodsFor: 'printing' stamp: 'sumim 9/7/2002 20:55'! printOn: aStream aStream nextPut: $'. aStream nextPutAll: self asString. aStream nextPut: $'! ! !漢数字桁 methodsFor: 'printing' stamp: 'sumim 9/7/2002 23:30'! 単位無用: 4か8 ^ ((桁 to: (桁 + 4か8 - 1 min: 配列 size)) select: [ :idx | (配列 at: 配列 size - idx + 1) 数字 ~~ $0 ]) size = 0! ! !SequenceableCollection methodsFor: 'converting' stamp: 'sumim 9/7/2002 23:08'! as漢数字配列 "Answer an 漢数字配列 whose elements are the elements of the receiver." ^ 漢数字配列 withAll: self asInteger asString! ! !漢数字配列 methodsFor: 'private' stamp: 'sumim 9/7/2002 20:06'! replaceFrom: start to: stop with: replacement startingAt: repStart | index repOff | repOff _ repStart - start. index _ start - 1. [(index _ index + 1) <= stop] whileTrue: [self at: index put: (漢数字桁 new 配列: self; 数字: (replacement at: repOff + index); 桁: self size - index + 1)]! ! !漢数字配列 methodsFor: 'converting' stamp: 'sumim 9/7/2002 21:56'! asString | stream | stream _ WriteStream on: (String new: 200). self do: [:each | stream nextPutAll: each asString ]. ^ stream contents! ! !漢数字配列 class methodsFor: 'examples' stamp: 'sumim 9/7/2002 23:33'! 例 ^ 100000000000000000000000000000000000000000000000000000000000000000000000000000001 as漢数字配列 asString "'壱不可思議壱'"! !