Language scheme
(slightly shorter, efficient, featureful)
Date: | 08/29/05 |
Author: | Ricardo Malafaia |
URL: | n/a |
Comments: | 1 |
Info: | http://www.schemers.org |
Score: | ![]() |
;; 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
Version | Author | Date | Comments | Rate |
---|---|---|---|---|
original version | Tim Goodwin | 04/20/05 | 2 | ![]() ![]() |
REALLY using hygienic macros | NMH | 02/02/11 | 0 | ![]() ![]() |
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 | ![]() ![]() |
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