real language

Bookmarking Digg Diigo DZone Earthlink Google
Windows Live LookLater Ma.gnolia Reddit Rojo StumbleUpon Technorati

Language ALGOL 68

Author:Otto Stolz
Score: (2.76 in 33 votes)
# 99 Bottles of Beer                         #
# by Otto Stolz <> #
( PROC width = (INT x) INT: (x>9 | 2 | 1)
; FOR i FROM 99 BY -1 TO 1
  DO  printf ( ( $ 2l n(width(i))d
                 , x "bottle" b("","s") x "of beer on the wall,"
                 , x n(width(i))d
                 , x "bottle" b("","s") x "of beer."
                 , l "Take one down, pass it around,"
                 , x n(width(i-1))d
                 , x "bottle" b("","s") x "of beer."
               , i  , i=1
               , i  , i=1
               , i-1, i=2
             ) )

Download Source | Write Comment

Alternative Versions


>>  Otto Stolz said on 08/23/07 12:51:10

Otto Stolz This extremely terse program exploits every possible abbreviation.

printf takes a row of formats, or expressions, as its sole argument
(the outer brackets delimit the argument list, the inner ones the row display).
A format is delimited by dollar signs; within it, frames are delimited by commas.

The (only) format in this example uses the following keys:
2 : repeat 2 times
l : new line
n : repeat n times, where n is yielded by the function call in brackets
d : digit
x : blank space
b : select an alternative from the bracket

A frame comprising a d key (at least) corresponds to an integer expression.
A frame comprising a b key (at least) corresponds to a Boolean expression.

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!




Security Code: