DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
Waiting For N Seconds In Scheme
// A means of causing evaluation to be delayed for a certain number of seconds in Scheme. May also be useful in LISP; I don't know. Most useful in begin expressions because it returns (void).
#lang scheme
;; wait : number -> void
;; Calls a local function that recurs on itself until n seconds have passed since wait was called.
(define wait
(lambda (n)
(local
[(define main
(lambda (x)
(cond
[(>= (current-milliseconds) (+ x (* n 1000)))
(void)]
[else
(main x)])))]
(main (current-milliseconds)))))




