[plt-scheme] iteration across cyclic graph
Hi,
I recently tried to work out how to cycle through a cycle (made with
the scheme/shared facilities);
(define colours (shared ([a (cons 'red b)]
[b (cons 'blue c)]
[c (cons 'green d)]
[d (cons 'yellow e)]
[e (cons 'orange a)])
a))
(define current-colours colours)
(define (get-colour)
(set! current-colours (cdr current-colours))
(car current-colours))
This does the job, but I'm not happy with either the expression and function.
Is there a better way?
Cheers,
Stephen