Voting

Category

real language

Bookmarking

Del.icio.us Digg Diigo DZone Earthlink Google Kick.ie
Windows Live LookLater Ma.gnolia Reddit Rojo StumbleUpon Technorati

Language GNU Desk Calculator

Date:04/20/05
Author:Anonymous
URL:n/a
Comments:1
Info:n/a
Score: (3.02 in 110 votes)
dc is the Desk Calculator for *nix; It works on reverse polish 
notation, and a few other commands. The output of this routine 
is a little jagged, as dc has no commands to control screen formatting.

 Usage: dc 99bottles                                

 where this source file is saved as 99bottles       
 NB: A blank line is required at the end of the file
     Without it, dc will not quit.
<PRE>
[   bottles of beer on the wall
]sa
[   bottles of beer
]sb
[   take one down, pass it around
]sc
[   
]sd
99sn
[lalnpsnPlblnp1-snPlcPlalnpsnPldPln0<x]sx
lxx
q

Download Source | Write Comment

Alternative Versions

Comments

>>  Zak Johnson said on 05/18/05 14:13:58

Zak Johnson The current 99bottles implementation in dc (GNU Desktop Calculator) has
sub-optimal output; I prefer my version (of course):

[[s]n]ss[[ bottle]n1ln!=s[ of beer]n]sb[ on the wall]sw[, ]sc[.]sp[2Q]sq[lnnlbx
lwnlcnlnnlbxlpp[Take one down, pass it around; ]nln1-sn0ln=qlnnlbxlwnlpplxx]sx
99snlxx[no more]nlbxlwnlpp

Or, somewhat less obfuscated:

[[s]n]ss
[[ bottle]n 1ln!=s [ of beer]n]sb
[ on the wall]sw
[, ]sc
[.]sp
[2Q]sq
[lnn lbx lwn lcn lnn lbx lpp
[Take one down, pass it around; ]n
ln1-sn 0ln=q lnn lbx lwn lpp lxx]sx
99sn lxx
[no more]n lbx lwn lpp

-Zak

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!

Name:

eMail:

URL:

Security Code:
  
Comment: