[plt-scheme] reverse operation - how fast?
Dear All,
Could someone tell me what the performance impact
is of the 'reverse' primitive in the code beneath:
*********************************************
(define (get-element-from-fifo fifo)
(let ((elem (car (reverse (car fifo)))))
(set-car! fifo (reverse (cdr (reverse (car fifo)))))
elem))
*********************************************
*********************************************
...rest of code...
(define (fifo? fifo)
(if (list? fifo)
(if (null? fifo)
#f
(if (null? (cdr fifo))
#f
(eq? (cadr fifo) 'fifo)))
#f))
(define (new-fifo) (list (list) 'fifo))
(define (empty-fifo? fifo)
(null? (car fifo)))
(define (add-element-to-fifo fifo elem)
(set-car! fifo (cons elem (car fifo))))
(define (empty-fifo! fifo)
(set-car! fifo (list)))
*********************************************
Thank you in advance for your answer,
Hans