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 IDL

(An example using IDL's array mapping)

Date:04/08/08
Author:Rüdiger Kupper
URL:http://ruedigerkupper.de
Comments:0
Info:http://en.wikipedia.org/wiki/IDL_(programming_language)
Score: (2.00 in 1 votes)
Pro beer
   
   ;; Demonstrate IDL's array mapping on the 99-bottles-of-beer lyrics.
   ;; usage:
   ;;   IDL> .compile beer.pro
   ;;   IDL> beer

   numbeer = 99-indgen(99)
   beers   = [strtrim(string(numbeer), 2), "No"]
   bottles = [replicate(" bottles", 98), " bottle", " bottles"]
   doaction= [replicate("Take one down and pass it around, ", 99), "Go to the store and buy some
more, "]
   
   newline = string(10b)+string(13b) 

   print, beers + bottles + " of beer on the wall, " +                                $
          strlowcase(beers) + bottles +" of beer." +                                  $
          newline +                                                                   $
          doaction +                                                                  $
          strlowcase(shift(beers,-1)) + shift(bottles,-1) + " of beer on the wall." + $
          newline
 
   ;; Note the most elegent use of the
   ;; beer-consuming, auto-buying shift function.

End

Download Source | Write Comment

Alternative Versions

VersionAuthorDateCommentsRate
1Eric Korpela04/20/051

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: