Functional coffee dispenser Inspired by this question, I decided to rewrite this code in Scheme, as I'm working through SICP right now. Any feedback welcome.

#lang racket

;assume cup, is-empty?, refill and drink are operations understood by the environment

(define (coffee cup)
        (if (is-empty? cup)
        (coffee (refill cup))
        (drink cup)))
In a Lisp dialect (Scheme, Racket, or anything else), indentation is rather important.  It doesn't determine anything about how the code works, but being able to visually parse the code is necessary, because the alternative is to count parentheses.  

With this indentation, you can visually see that the 2 lines after the if are part of the if statement:

(define (coffee cup)
  (if (is-empty? cup)
      (coffee (refill cup))
      (drink cup)))


I just copy-pasted the code into Emacs, told it to switch to scheme mode, and then told it to reindent.  You don't have to use Emacs, but you should use an editor that understands the Lisp dialect you're using.  If you mess up the parentheses, the editor will indent things oddly, and you can visually see that it's wrong without having to count parentheses.