(define flip
  (let ((state #f))
    (lambda ()
      (set! state (not state))
      (if state 1 0))))