examples/example-0.ss
#lang scheme/base
; Example 0 - Functions as Events

(require (planet williams/simulation/simulation))
(require (planet williams/science/random-distributions))

(define (generator n)
  (for ((i (in-range n)))
    (wait (random-exponential 4.0))
    (schedule now (customer i))))

(define (customer i)
  (printf "~a: customer ~a enters~n"
          (current-simulation-time) i)
  (work (random-flat 2.0 10.0))
  (printf "~a: customer ~a leaves~n"
          (current-simulation-time) i))

(define (run-simulation n)
  (with-new-simulation-environment
   (schedule (at 0.0) (generator n))
   (start-simulation)))

(run-simulation 10)