Voting

Category

real language

Bookmarking

Del.icio.us Digg Diigo DZone Earthlink Google Kick.ie
Windows Live LookLater Ma.gnolia Reddit Rojo StumbleUpon Technorati

Language OmniMark

(OmniMark is a text processing language)

Date:01/31/06
Author:Jacques Legare
URL:n/a
Comments:0
Info:http://www.stilo.com
Score: (3.01 in 117 votes)
define string source function
   wordy value integer i
as
   local string units initial { "one", "two", "three", "four", "five", 
                                "six", "seven", "eight", "nine" }
   local string teens initial { "ten", "eleven", "twelve", "thirteen", 
                                "fourteen", "fifteen", "sixteen", "seventeen",
                                "eighteen", "nineteen" }
   local string tens  initial { "twenty", "thirty", "forty", "fifty", "sixty", 
                                "seventy", "eighty", "ninety" }

   do select i
   case 0
      output "zero"

   case 1 to 9
      using input as units[i] 
         output "ug" % (#current-input take any) || #current-input

   case 10 to 19
      using input as teens[i - 9] 
         output "ug" % (#current-input take any) || #current-input

   else
      using input as tens[i / 10 - 1] 
         output "ug" % (#current-input take any) || #current-input
      output " " || units[i modulo 10]
         unless i modulo 10 = 0
   done


process
   repeat for integer i from 99 to 0 by -1
      submit wordy i
   again


find ul"zero"
   output "No more bottles of beer on the wall,%n"
       || "No more bottles of beer.%n"
       || "Go to the store and buy some more,%n"
       || "Ninety nine bottles of beer on the wall.%n%n"


find ul"one" value-end
   output "One bottle of beer on the wall!%n%n"
       || "One bottle of beer on the wall,%n"
       || "One bottle of beer.%n"
       || "Take one down, pass it around.%n"
       || "No more bottles of beer on the wall.%n%n"


find any+ => n
   output n || " bottles of beer on the wall.%n%n"
      unless n = ul"ninety nine"
   output n || " bottles of beer on the wall,%n"
       || n || " bottles of beer.%n"
       || "Take one down, pass it around,%n"

Download Source | Write Comment

Alternative Versions

Comments

Download Source | Write Comment

Add Comment

Please provide a value for the fields Name, Comment and Security Code.
This is a gravatar-friendly website.
E-mail addresses will never be shown.
Enter your e-mail address to use your gravatar.

Please don't post large portions of code here! Use the form to submit new examples or updates instead!

Name:

eMail:

URL:

Security Code:
  
Comment: