From 87943e435b2c8c38600b8e7c9119de001eb28107 Mon Sep 17 00:00:00 2001 From: Tony Garnock-Jones Date: Fri, 17 Feb 2012 16:09:23 -0500 Subject: [PATCH] Replace use of first-only with match --- driver.rkt | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/driver.rkt b/driver.rkt index abfa539..1569875 100644 --- a/driver.rkt +++ b/driver.rkt @@ -64,11 +64,6 @@ (spawn udp-driver) (spawn (nested-vm boot-server))))) -(define (first-only xs) - (if (null? xs) - xs - (list (car xs)))) - (define (handle-request soa-rr zone request) (match-define (dns-request request-message request-source request-sink) request) @@ -133,9 +128,10 @@ ;; TODO: check opcode and direction in request ;; TODO: think again about multiple questions in one packet - (map (lambda (q) - (dns-reply (answer-question q make-reply) request-sink request-source)) - (first-only (dns-message-questions request-message)))) + (match (dns-message-questions request-message) + ['() '()] + [(cons q _) + (list (dns-reply (answer-question q make-reply) request-sink request-source))])) (require "test-rrs.rkt") (start-server (test-port-number) test-soa-rr test-rrs)