Language ALGOL 68
Date: | 04/20/05 |
Author: | Otto Stolz |
URL: | n/a |
Comments: | 1 |
Info: | n/a |
Score: | (2.83 in 35 votes) |
# 99 Bottles of Beer #
# by Otto Stolz <Otto.Stolz@Uni-Konstanz.de> #
( 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
) )
OD
)
Download Source |
Write Comment
Download Source |
Write Comment
Comments
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.