# RE: 99 bottles

```It seems to me that all this talk of rubies, perls and effusive reptiles is
superfluous, when really, all this problem needs is a bit of functional
abstraction!

Assuming a lambda calculus with a Y combinator, a display function d,
strings, integers, subtraction, >, and zero?, the program can be written
like this:

((\b w.
((Y (\h.
(\x. (d x b w x b "\nTake one down, pass it around\n")
((\x. (d ((= x 0) "No" x) b w "\n")
((> x 0)(h x)))(- x 1))))) 99)) " bottles of beer" " on the
wall\n")

The exact syntax would need to be tweaked for the lambda calculator being
used - there are probably some extra parens in there now.  The above version
is 160 characters excluding superfluous whitespace - a hair's breadth away
from the given Python version.

But if you factor in the size of the interpreter needed, the winner is
clear!  Who needs all those extra "features" and "syntax"???  Well, I
suppose Larry, Guido, and Matz have to keep themselves busy somehow...!!

For completeness, a working Scheme version of the above, with supporting
functions, is listed below (works in PLT, JScheme, MIT Scheme...)  Of
course, the below can be made smaller with full Scheme, if you allow the use
of e.g. let clauses and direct recursion support.

--Anton

(define (d . s) (map display s))

(define Y
(lambda (h)
((lambda (x) (h (lambda (n) ((x x) n))))
(lambda (x) (h (lambda (n) ((x x) n)))))))

((lambda (b w)
((Y (lambda (h)
(lambda (x)
(d x b w x b "\nTake one down, pass it around\n")
((lambda (x)
(d (if (zero? x) "No" x) b w "\n")
(if (> x 0) (h x)))(- x 1))))) 99))
" bottles of beer"
" on the wall\n")

```

• Follow-Ups: