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
Version | Author | Date | Comments | Rate |
---|---|---|---|---|
slightly shorter, efficient, featureful | Ricardo Malafaia | 08/29/05 | 1 | |
define-less version | lambda the ultimate | 10/14/10 | 0 | |
uses the hygenic macro system | Evan Farrer | 08/11/05 | 2 | |
Cleanly factored MAP-based version | Gnomon | 04/18/08 | 2 | |
REALLY using hygienic macros | NMH | 02/02/11 | 0 |
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!
Comments
Paul said on 07/13/09 15:35:32
Beautiful and elegant.
Ryan said on 12/13/09 17:41:51
Beautiful and elegant = clever?