From: Tom Culliton <culliton@clark.net>
To: culliton@clark.net, rc@hawkwind.utcs.toronto.edu, rsc@research.att.com
Subject: re: 99 bottles in an rc shell script.
Date: Thu, 1 May 1997 01:02:48 -0400 [thread overview]
Message-ID: <199705010502.BAA29092@explorer2.clark.net> (raw)
> 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
}
next reply other threads:[~1997-05-01 6:48 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
1997-05-01 5:02 Tom Culliton [this message]
-- strict thread matches above, loose matches on Subject: below --
1997-05-01 21:13 Mark K. Gardner
1997-05-01 19:28 Byron Rakitzis
1997-05-01 17:14 Tom Culliton
1997-05-01 4:03 Tom Culliton
1997-05-01 1:29 rsc
1997-04-30 22:26 Tom Culliton
1997-05-01 1:57 ` David Luyer
1997-05-01 16:33 ` Paul Haahr
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=199705010502.BAA29092@explorer2.clark.net \
--to=culliton@clark.net \
--cc=rc@hawkwind.utcs.toronto.edu \
--cc=rsc@research.att.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).