racket/collects/tests/eopl/chapter5/thread-lang/queues.rkt
David Van Horn 7491e172ea EOPL test suite re-written in Racket-based #lang eopl and rackunit
The eopl language is now racket-based rather than mzscheme-based.  This
test-suite, which was originally distributed on the book's web-site has
been re-written in the new language.  Changes include dropping all
drscheme-init.scm and top.scm files.  Remaining files were renamed to
use the .rkt extension and edited to use the #lang syntax (instead of
modulue).  Require and provide forms were changed to reflect racket's
syntax instead of mzscheme's (eg, only-in vs. only).  Several
occurrences of one-armed ifs were changed to use when and unless.  All
tests have been run successfully.
2012-02-24 14:46:18 -05:00

26 lines
414 B
Racket
Executable File

#lang eopl
(provide (all-defined-out))
;; queues
;; We maintain the queue by adding to the end and dequeuing from the
;; front.
;; exercise: enqueue is expensive, since it uses append. Do
;; something better than this.
(define empty-queue
(lambda ()
'()))
(define empty? null?)
(define enqueue
(lambda (q val)
(append q (list val))))
(define dequeue
(lambda (q f)
(f (car q) (cdr q))))