IBM®
Skip to main content
    Country/region select      Terms of use
 
 
   
     Home      Products      Services & solutions      Support & downloads      My account     

developerWorks  >  Lotus  >  Forums & community  >  Best Practice Makes Perfect

Best Practice Makes Perfect

A collaboration with Domino developers about how to do it and how to get it right in Domino

Here's a little function to take an integer and write it out in words (e.g. input = 34, output = "thirty-four") -- see attached file. This is also another example of recursion. This one's a little harder to convert to iterative since it calls itself at multiple points (and there's less incentive to because the deepest level of recursion it can reach is fairly shallow -- 2 levels). Exercise for the reader: produce an iterative implementation.

It hasn't been optimized for performance either.

Andre Guirard | 14 April 2008 08:34:13 AM ET | Home, Plymouth, MN, USA | Comments (2)


 Comments

1) Write out number function, and a challenge
Matt White | 4/14/2008 9:26:07 AM

Very nice.

I had a similar requirement last year but to be able to write the number out in English and French (different grammar) etc, so here is my version...

{ Link }

Matt

2) Write out number function, and a challenge
Charles Robinson | 4/14/2008 2:40:59 PM

Here's some test results:

2117562743

two billion one hundred seventeen million five hundred sixty-two thousand seven hundred forty-three

0.002088 seconds

Even moving populating the arrays outside the function it doesn't speed things up appreciably.

Very good job, sir, and something I can use immediately. :-)

3) "Write out number" function, and a challenge
Andre Guirard | 4/14/2008 6:06:47 PM

After I posted, it occurred to me that I could've made the arrays Const strings and used StrToken, which might not be faster but is certainly shorter. Oh well. There are functions one gets used to using and other functions one just sort of forgets about.

 Add a Comment
Subject:
   
Name:
Comment:  (No HTML - Links will be converted if prefixed http://)
 
Remember Me?     Cancel

Search this blog 

Disclaimer 

    About IBM Privacy Contact