guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

(ice-9 optargs) #:rest


From: Thien-Thi Nguyen
Subject: (ice-9 optargs) #:rest
Date: Wed, 14 Nov 2001 11:20:29 -0800

i'm using (ice-9 optargs) like so:

(use-modules (ice-9 optargs))
(define* (blah #:key (j 'j) (k 'k) #:rest x)
  (list blah j k x))

on invocation, i see:

(blah #:j 'JAY #:k KAY '(1 2 3))
=> (#<procedure blah x> JAY KAY (#:j JAY #:k KAY (1 2 3)))

but what i'd really like to see is:
=> (#<procedure blah x> JAY KAY ((1 2 3)))

i've written `remove-keys' (see below) for use like
  (set! x (remove-keys x))
but that seems like a really ugly hack.  is there a better way?

thi

____________________________________________
(define (remove-keys ls)
  (let loop ((ls ls) (acc '()))
    (if (null? ls)
        (reverse acc)
        (let ((kw? (keyword? (car ls))))
          (loop ((if kw? cddr cdr) ls)
                (if kw? acc (cons (car ls) acc)))))))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]