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 dtrace

Date:05/13/05
Author:Sean McGrath
URL:n/a
Comments:1
Info:http://blogs.sun.com/smg
Score: (3.01 in 98 votes)
#!/usr/sbin/dtrace -qs

/* Dtrace version of bottles of beer
 * Written by Sean McGrath
 * http://blogs.sun.com/smg
 */

BEGIN
{
        n = 3;
        ifor = 1;
}

tick-1sec
/!n && !ifor/
{
        printf("No more bottles of beer on the wall\n\n");
        printf("Time to buy more beer!\n");
        exit(0);
}

tick-1sec
/n == 1 && !ifor/
{
        printf("one more bottle of beer on the wall\n\n");
        printf("one more bottle of beer on the wall\n");
        ifor = 1;
}

tick-1sec
/n > 1 && !ifor/
{
        printf("%d bottles of beer on the wall\n\n", n);
        printf("%d bottles of beer on the wall\n", n);
        printf("%d bottles of beeeeer . . .\n", n);
        printf("Take one down, pass it around,\n");
        ifor = 1;
}

tick-1sec
/ifor/
{
        n--;
        ifor = 0;
}

Download Source | Write Comment

Alternative Versions

Comments

>>  Devo H. O'Dell said on 10/29/05 10:46:38

Devo H. O'Dell Nice to see this here. Only one comment -- isn't the language called ``D''? ISTR that DigitalMars got pissy at Sun for naming their language similarly.

--Devon

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: