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 PLT Scheme

(language is used to teach beginners (DE)

Date:05/27/09
Author:Thure Dührsen
URL:n/a
Comments:2
Info:http://www.plt-scheme.org/
Score: (2.98 in 45 votes)
(define (bottles n)
  (display
   (string-append 
    (cond ((= n 0) "No more bottles")
          ((= n 1) "One bottle")
          (else (string-append (number->string n) " bottles"))) " of beer")))

(define (beer 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))
        )      
      null
      )
  )

(beer 99)

Download Source | Write Comment

Alternative Versions

Comments

>>  MoonJackie said on 03/15/10 10:18:35

MoonJackie Buildings are not cheap and not everybody can buy it. But, <a href="http://lowest-rate-loans.com/topics/home-loans">home loans</a> are created to aid different people in such hard situations.

>>  barrym said on 07/15/10 05:16:22

barrym The source runs fine, but the output suffers from missing punctuation and
a missing final verse!

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: