Writer takes a generator, coroutines!
This commit is contained in:
16
demo.scm
16
demo.scm
@@ -19,13 +19,11 @@
|
||||
(cdr pair))))
|
||||
graph))
|
||||
|
||||
(define* (heap-unfold heap #:optional (infinites? #f))
|
||||
(if (and (heap-peek heap) (or infinites? (finite? (car (heap-peek heap)))))
|
||||
(cons (heap-peek heap) (heap-unfold (heap-pop heap) infinites?))
|
||||
'()))
|
||||
|
||||
(define graphs '())
|
||||
(djikstra graph 90 9 (lambda (visited heap)
|
||||
(set! graphs (cons (color-graph graph visited heap) graphs))))
|
||||
(write-graphs-to-file (reverse-list->vector graphs) "djikstra.webp")
|
||||
(define graph-generator
|
||||
(make-generator
|
||||
(lambda (yield)
|
||||
(djikstra graph 90 9 (lambda (visited heap)
|
||||
(yield (color-graph graph visited heap))))
|
||||
#f)))
|
||||
|
||||
(write-graphs-to-file "djikstra.webp" graph-generator)
|
||||
|
||||
Reference in New Issue
Block a user