cl:list-of??   scheme


Defined in:  https://github.com/digego/extempore/tree/v0.8.9/runtime/scheme.xtm

Implementation

(define (cl:list-of?? predicate . bound)
  (define (errout) (apply slib:error 'list-of?? predicate bound))
  (case (length bound)
    ((0)
     (lambda (obj)
       (and (list? obj)
      (cl:every predicate obj))))
    ((1)
     (set! bound (car bound))
     (cond ((negative? bound)
      (set! bound (- bound))
      (lambda (obj)
        (and (list? obj)
       (<= bound (length obj))
       (cl:every predicate obj))))
     (else
      (lambda (obj)
        (and (list? obj)
       (<= (length obj) bound)
       (cl:every predicate obj))))))
    ((2)
     (let ((low (car bound))
     (high (cadr bound)))
       (cond ((or (negative? low) (negative? high)) (errout))
       ((< high low)
        (set! high (car bound))
        (set! low (cadr bound))))
       (lambda (obj)
   (and (list? obj)
        (<= low (length obj) high)
        (cl:every predicate obj)))))
    (else (errout))))
;@


Back to Index