vector.scm 730 B

1234567891011121314151617181920212223242526272829303132333435
  1. ; Part of Scheme 48 1.9. See file COPYING for notices and license.
  2. ; Authors: Richard Kelsey
  3. ; Oops - this is polymorphic!
  4. (define (vector+length-fill! v length x)
  5. (do ((i 0 (+ i 1)))
  6. ((>= i length))
  7. (vector-set! v i x)))
  8. (define *v* (unassigned))
  9. (define (test x)
  10. (set! *v* (make-vector 10))
  11. (vector+length-fill! *v* 10 3)
  12. (vector-ref *v* x))
  13. ;(define (find-port-index)
  14. ; (let loop ((i 0))
  15. ; (cond ((>= i 10)
  16. ; -1)
  17. ; ((= 3 (vector-ref *v* i))
  18. ; i)
  19. ; (else (loop (+ i 1))))))
  20. ;
  21. ;(define (foo)
  22. ; (let loop ((i (find-port-index)))
  23. ; (if (>= i 5)
  24. ; (let ((v *v*))
  25. ; (bar)
  26. ; (vector-set! v i (baz)))
  27. ; (loop (find-port-index)))))