From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from netcom9.netcom.com ([192.100.81.119]) by hawkwind.utcs.utoronto.ca with SMTP id <24710>; Thu, 1 May 1997 16:59:18 -0400 Received: (from haahr@localhost) by netcom9.netcom.com (8.6.13/Netcom) id JAA16436; Thu, 1 May 1997 09:33:37 -0700 Date: Thu, 1 May 1997 12:33:37 -0400 From: haahr@netcom.com (Paul Haahr) Message-Id: <199705011633.JAA16436@netcom9.netcom.com> To: Tom Culliton Cc: TimTroyR@ionet.net, rc@hawkwind.utcs.toronto.edu Subject: Re: 99 bottles in an rc shell script. In-Reply-To: <199704302226.SAA03968@clark.net> References: <199704302226.SAA03968@clark.net> Why enumerate all the numbers? Why use some external program? Peano arithmetic is more than sufficient. (While I was at it, I rearranged the loop a little. And I didn't use the elseif constructs because I wanted compatibility between Byron's rc and Plan 9 rc, as well as forgetting what they are.) #! /usr/local/bin/rc * = 0 while (! ~ $#* 100) * = ($#* $*) bottles = bottles one = one punct = . while (true) { echo $1 $bottles of beer on the wall, echo $1 $bottles of beer, echo take $one down and pass it around, shift if (~ $1 1) { bottles = bottle one = it } count = ($1 $one) if (~ $1 0) { count = (no more) bottle = bottles punct = ! } echo $count $bottles of beer on the wall^$punct if (~ $1 0) break echo }