File: vector.scm

package info (click to toggle)
scheme48 1.8%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 14,980 kB
  • ctags: 14,127
  • sloc: lisp: 76,272; ansic: 71,514; sh: 3,026; makefile: 637
file content (32 lines) | stat: -rw-r--r-- 699 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
; Copyright (c) 1993-2008 by Richard Kelsey.  See file COPYING.


; Oops - this is polymorphic!

(define (vector+length-fill! v length x)
  (do ((i 0 (+ i 1)))
      ((>= i length))
    (vector-set! v i x)))

(define *v* (unassigned))

(define (test x)
  (set! *v* (make-vector 10))
  (vector+length-fill! *v* 10 3)
  (vector-ref *v* x))

;(define (find-port-index)
;  (let loop ((i 0))
;    (cond ((>= i 10)
;           -1)
;          ((= 3 (vector-ref *v* i))
;           i)
;          (else (loop (+ i 1))))))
;
;(define (foo)
;  (let loop ((i (find-port-index)))
;    (if (>= i 5)
;        (let ((v *v*))
;          (bar)
;          (vector-set! v i (baz)))
;        (loop (find-port-index)))))