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 Scheme

(original version)

Date:04/20/05
Author:Tim Goodwin
URL:n/a
Comments:2
Info:n/a
Score: (4.13 in 652 votes)
;;; Tim Goodwin (tim@pipex.net)

(define bottles
  (lambda (n)
    (cond ((= n 0) (display "No more bottles"))
          ((= n 1) (display "One bottle"))
          (else (display n) (display " bottles")))
    (display " of beer")))

(define beer
  (lambda (n)
    (if (> n 0)
        (begin
          (bottles n) (display " on the wall") (newline)
          (bottles n) (newline)
          (display "Take one down, pass it around") (newline)
          (bottles (- n 1)) (display " on the wall") (newline)
          (newline)
          (beer (- n 1))))))

(beer 99)

Download Source | Write Comment

Alternative Versions

VersionAuthorDateCommentsRate
slightly shorter, efficient, featurefulRicardo Malafaia08/29/051
define-less versionlambda the ultimate10/14/100
uses the hygenic macro systemEvan Farrer08/11/052
Cleanly factored MAP-based versionGnomon04/18/082
REALLY using hygienic macrosNMH02/02/110

Comments

>>  Paul said on 07/13/09 15:35:32

Paul Beautiful and elegant.

>>  Ryan said on 12/13/09 17:41:51

Ryan Beautiful and elegant = clever?


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: