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

(slightly shorter, efficient, featureful)

Date:08/29/05
Author:Ricardo Malafaia
URL:n/a
Comments:1
Info:http://www.schemers.org
Score: (2.96 in 25 votes)
;; rmalafaia@gmail.com, 2005-08-29
;; slightly shorter and more efficient
;; some more language features shown as well

(let ((str+ string-append)
      (n->s number->string))
  (define (bottles n)
    (str+ (case n
	    ((0) "No more bottles")
	    ((1) "One bottle")
	    (else (str+ (n->s n)
			" bottles")))
	  " of beer"))
  (define (beer n)
    (if (> n 0)
	(let ((bn (bottles n))
	      (msg (lambda (b cmp)
		     (display (str+ b cmp))
		     (newline))))
	  (msg bn " on the wall")
	  (msg bn "")
	  (msg "Take one down, pass it around" "")
	  (msg (bottles (- n 1)) " on the wall")
	  (newline)
	  (beer (- n 1)))))
  (beer 99))

Download Source | Write Comment

Alternative Versions

VersionAuthorDateCommentsRate
original versionTim Goodwin04/20/052
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

>>  RiceDEIDRE22 said on 03/10/10 05:26:01

RiceDEIDRE22 Every body remembers that today's life seems to be very expensive, nevertheless some people need money for various stuff and not every man gets big sums money. Thus to receive some <a href="http://lowest-rate-loans.com/topics/home-loans">home loans</a> or just car loan will be good way out.

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: