diff options
author | David Thompson <dthompson2@worcester.edu> | 2021-04-28 21:09:43 -0400 |
---|---|---|
committer | David Thompson <dthompson2@worcester.edu> | 2021-04-28 21:09:43 -0400 |
commit | 5455bb27b00108920a566bdfb4eea21b2d7e4569 (patch) | |
tree | 9be05fe23ff162dd2859f51f6d0a6eabae90698f | |
parent | d4f19639bd4c7094a8e146f27427b8ebe033a499 (diff) |
queue: Add queue-clear! procedure.
-rw-r--r-- | chickadee/queue.scm | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/chickadee/queue.scm b/chickadee/queue.scm index 51cec76..39f6318 100644 --- a/chickadee/queue.scm +++ b/chickadee/queue.scm @@ -25,7 +25,8 @@ queue-length queue-empty? enqueue! - dequeue!)) + dequeue! + queue-clear!)) (define-record-type <queue> (%make-queue input output) @@ -66,3 +67,8 @@ (array-list-push! output (array-list-pop! input)) (loop)))) (array-list-pop! output)))) + +(define (queue-clear! q) + "Remove all items from Q." + (array-list-clear! (queue-input q)) + (array-list-clear! (queue-output q))) |