Language bash
(with arrays and functions)
Date: | 06/30/06 |
Author: | Vittorio Cagnetta |
URL: | n/a |
Comments: | 0 |
Info: | http://www.gnu.org/software/bash/ |
Score: | (2.82 in 11 votes) |
#!/bin/bash # Bourne Again shell version (yet another) of 99 Bottles # Vittorio Cagnetta - vaisarger@yahoo.it strophe() { echo "\ ${n} ${bottles[0]} of beer on the wall, ${n} ${bottles[0]} of beer, take one down, pass it around, ${N} ${bottles[1]} of beer on the wall. " } bottles=( [0]=bottles [1]=bottles ) for (( n=99,N=98 ; n>0 ; n--,N-- )); do if [ ${N} -eq 1 ]; then bottles[1]=bottle elif [ ${N} -eq 0 ]; then bottles=( [0]=bottle [1]=bottles ) && N=no fi strophe done
Download Source | Write Comment
Alternative Versions
Version | Author | Date | Comments | Rate |
---|---|---|---|---|
No loop, no recursion | Frédéric Lang | 07/08/08 | 3 | |
Self Writing | Olosta | 07/18/12 | 0 | |
Bourne Again Shell | Dave Plonka | 04/20/05 | 5 | |
portable, rich of features, readable | Bastian Bittorf | 08/20/07 | 0 | |
Arithmetic on English words for numbers | Bill Brown | 07/31/08 | 0 | |
recursive function | Koen Noens | 12/30/07 | 0 |
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!
Comments