[plt-scheme] Keyword args

From: Alex Peake (alex.peake at comac.com)
Date: Fri Oct 22 00:41:36 EDT 2004

;; Scans a Lisp-style keyword/value property list.
(define (getarg initargs name . not-found)
  (define (scan tail)
    (cond ((null? tail) (if (pair? not-found)
                            (car not-found)
                            (error 'getarg "couldn't find ~e." name)))
          ((null? (cdr tail)) (error 'getarg "keyword list not balanced ~e." (car tail)))
          ((eq? (car tail) name) (cadr tail))
          (else (scan (cddr tail)))))
  (scan initargs)))



Posted on the users mailing list.