Waiting for the result of a large computation can be annoying.
Is the loop stuck?
The silly sequence below makes it easy to do something every nth
time in a loop.
Such as displaying a progress indicator.
#lang racket
(define (in-heartbeat n beat)
(make-do-sequence
(lambda ()
(values (λ (pos) (when (= pos n) (beat)) #f) ; pos->element
(λ (pos) (if (= pos n) 0 (+ pos 1))) ; next-pos
0 ; initial-pos
(λ (pos) #t) ; continue?
#f
#f))))
(for/sum ([i 100]
[x (in-heartbeat 10 (λ () (display ".")))])
i)
; .........4950