#lang racket/base
;;; SPDX-License-Identifier: LGPL-3.0-or-later
;;; SPDX-FileCopyrightText: Copyright © 2021 Tony Garnock-Jones <tonyg@leastfixedpoint.com>

(provide make-counter)

(define (make-counter [start-value 0])
  (define next-value start-value)
  (lambda ()
    (let ((v next-value))
      (set! next-value (+ v 1))
      v)))
