From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail.clark.net ([168.143.0.10]) by hawkwind.utcs.utoronto.ca with SMTP id <24668>; Thu, 1 May 1997 02:48:06 -0400 Received: from explorer2.clark.net (culliton@explorer2.clark.net [168.143.0.5]) by mail.clark.net (8.8.5/8.6.5) with ESMTP id BAA03439; Thu, 1 May 1997 01:02:27 -0400 (EDT) From: Tom Culliton Received: (from culliton@localhost) by explorer2.clark.net (8.8.5/8.7.1) id BAA29092; Thu, 1 May 1997 01:02:48 -0400 (EDT) Date: Thu, 1 May 1997 01:02:48 -0400 Message-Id: <199705010502.BAA29092@explorer2.clark.net> To: culliton@clark.net, rc@hawkwind.utcs.toronto.edu, rsc@research.att.com Subject: re: 99 bottles in an rc shell script. > This introduces a little more code in return for > losing the count array. > > #!/bin/rc > # rc shell version of 99 bottles of beer > # by Tom Culliton (culliton@clark.net) > # revised by Russ Cox (rsc@research.att.com) > > bottles = bottles; one = one > digits = (9 8 7 6 5 4 3 2 1 0) > for(i in $digits) for(j in $digits) { > n = $i$j > if(~ $i 0) n = $j > if(! ~ $n 0) { > if(~ $n 1) { bottles = bottle; one = it } > if(! ~ $n 99) { > echo $n $bottles 'of beer on the wall.' > echo > } > echo $n $bottles 'of beer on the wall,' > echo $n $bottles 'of beer,' > echo 'take' $one 'down and pass it around,' > } > } > echo 'no more bottles of beer on the wall!' This reminds me of an even more "rc like" way to do this with just builtins... ;-) ;-) ;-) ten = (beer beer beer beer beer beer beer beer beer beer) * = ($ten $ten $ten $ten $ten $ten $ten $ten $ten $ten) shift ; bottles = $#*^' bottles' ; one = one while (! ~ $* ()) { echo $bottles 'of beer on the wall,' ; echo $bottles 'of beer,' echo 'take' $one 'down and pass it around,' shift ; switch ($#*) { case 1 ; bottles = '1 bottle' ; one = it case 0 ; bottles = 'no more bottles' case * ; bottles = $#*^' bottles' } echo $bottles 'of beer on the wall.' ; echo }