Skip to content

Instantly share code, notes, and snippets.

@jgreco
Created August 28, 2019 00:00
Show Gist options
  • Save jgreco/147503479916d08e3efb6291678f6016 to your computer and use it in GitHub Desktop.
Save jgreco/147503479916d08e3efb6291678f6016 to your computer and use it in GitHub Desktop.
(define (sync/vector evts-v)
(let ([sync-vec (build-vector (vector-length evts-v)
(lambda (n)
(wrap-evt
(vector-ref evts-v n)
(lambda (r) (cons n r)))))])
(let loop ()
(let ([remaining-evts (filter evt? (vector->list sync-vec))])
(unless (empty? remaining-evts)
(let ([res (apply sync remaining-evts)])
(vector-set! sync-vec (car res) (cdr res)))
(loop))))
sync-vec))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment