On Thu, 21 Dec 2000, Raja S. wrote:

> David Alan Black <dblack / candle.superlink.net> writes:
> 
> >Input:   123456
> >Output:  "one-hundred twenty-three thousand four-hundred fifty-six"
> >Solutions in other languages welcome too.
> 
> Common Lisp's 'format' routine offers this as a built-in facility with the
> ~r directive:
> 
> * (format t "~r" 12345678901234567890)

OK, here's my new Ruby solution:

ruby -e "system %q{gcl -batch -eval '(format t \"~r\" 123)'}"

:-)

> twelve quintillion three hundred forty-five quadrillion six hundred
> seventy-eight trillion nine hundred one billion two hundred thirty-four
> million five hundred sixty-seven thousand eight hundred ninety

The consensus seems to be: no hyphens except where n < 100.  I guess
my instincts were wrong.

> I had a need for something similar (though upto a million would have
> sufficed) a short while ago and wrote an equivalent in Python.  A mechanical
> transilteration to Ruby is also available:
> 
> http://www.cs.indiana.edu/~raja/code/Cardinal.py
> http://www.cs.indiana.edu/~raja/code/Cardinal.rb

Haven't looked, but will.  Meanwhile, I've put my Perl version (minus
the hyphens) at <http://icarus.shu.edu/dblack/inttoeng.pl>.  (The Perl
version also does ordinal numbers -- "twenty-second" etc.)


David

-- 
David Alan Black
home: dblack / candle.superlink.net
work: blackdav / shu.edu
Web:  http://pirate.shu.edu/~blackdav