Copied from http://jsoftware.com/jwiki/Essays/Number_in_Words :
zh4=: 4 : 0 NB. x: 1 iff leading group; y: number < 1e4
b=. 0<d=. 10 10 10 10#:y
p=. +./\ b>:x
s=. +./\. b
t=. 0 0 1 0*.0 1-:1 2{d
' ' -.~ ; ((0=y){.ZH10) , (p*.s) # t}.&.> (d{ZH10) ,&.> b $&.> ZH4
)
zh=: 3 : 0
d=. 10000&#.^:_1 y
assert. (0<:y) *. ((=<.)y) *. d <:&# ZHU
t=. ; (+./\.*d) # (((#d){.1)zhg&.>d) ,&.> (*d)#&.>|.(#d){.ZHU
z=. >{.ZH10 NB. zero
((0=y)#z) , t{~(i.#t)-.,(i.#z)+/(,~z) [EMAIL PROTECTED] t
)
zh 123456789
|value error: zhg
| t=.;(+./\.*d)#(((#d){.1) zhg&.>d),&.>(*d)#&.>|.(#d){.ZHU
zhg isn't defined there. I supposed zh4 could be zhg. However, after
assigning that name to zh4, the result is:
zh 123456789
一億二三四五萬六七八九
, which is different from the wiki page:
zh 123456789
一億二千三百四十五萬六千七百八十九
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm