Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
25 lines (21 sloc) 531 Bytes
;; More essential stuff for queues
(define (queue-assoc x q)
(assoc x (queue-head q)))
(define (queue-any p q)
(any p (queue-head q)))
(define (dequeue-first! p q)
(let loop ((pair (queue-head q))
(last-pair '()))
((null? pair) #f)
((p (car pair))
(let ((value (car pair))
(next (cdr pair)))
(if (pair? last-pair)
(set-cdr! last-pair next)
(set-queue-head! q next))
(if (null? next)
(set-queue-tail! q last-pair))
(loop (cdr pair) pair)))))
Something went wrong with that request. Please try again.