(index ("make-vector" 0) ("vector" 360) ("vector-unfold" 572) ("vector-unfold-right" 1628) ("vector-copy" 2425) ("vector-reverse-copy" 3252) ("vector-append" 3542) ("vector-concatenate" 3942) ("vector-append-subvectors" 4293) ("vector?" 4714) ("vector-empty?" 5085) ("vector=" 5407) ("vector-ref" 7101) ("vector-length" 7479) ("vector-fold" 7975) ("vector-fold-right" 9069) ("vector-map" 9439) ("vector-map!" 10325) ("vector-for-each" 10776) ("vector-count" 11424) ("vector-cumulate" 11911) ("vector-index" 12396) ("vector-index-right" 12899) ("vector-skip" 13134) ("vector-skip-right" 13680) ("vector-binary-search" 14110) ("vector-any" 14999) ("vector-every" 15384) ("vector-partition" 15838) ("vector-set!" 16306) ("vector-swap!" 16464) ("vector-fill!" 16612) ("vector-reverse!" 16901) ("vector-copy!" 17228) ("vector-reverse-copy!" 17806) ("vector-unfold!" 18056) ("vector-unfold-right!" 18397) ("vector->list" 18667) ("reverse-vector->list" 18935) ("list->vector" 19142) ("reverse-list->vector" 19279) ("string->vector" 19476) ("vector->string" 19759))
(def (sig (procedure "(make-vector size [fill])" (id make-vector))) (p "[R7RS-small] Creates and returns a vector of size " (tt "size") ". If " (tt "fill") " is specified, all the elements of the vector are initialized to " (tt "fill") ". Otherwise, their contents are indeterminate.") (p "Example:") (highlight scheme "(make-vector 5 3)\n ;=> #(3 3 3 3 3)"))
(def (sig (procedure "(vector x ...)" (id vector))) (p "[R7RS-small] Creates and returns a vector whose elements are " (tt "x ...") ".") (p "Example:") (highlight scheme "(vector 0 1 2 3 4)\n ;=> #(0 1 2 3 4)"))
(def (sig (procedure "(vector-unfold f length initial-seed ...)" (id vector-unfold))) (p "The fundamental vector constructor. Creates a vector whose length is " (tt "length") " and iterates across each index k between 0 and " (tt "length") ", applying " (tt "f") " at each iteration to the current index and current seeds, in that order, to receive n + 1 values: first, the element to put in the kth slot of the new vector and n new seeds for the next iteration. It is an error for the number of seeds to vary between iterations. Note that the termination condition is different from the " (tt "unfold") " procedure of SRFI 1.") (p "Examples:") (highlight scheme "(vector-unfold (lambda (i x) (values x (- x 1)))\n                 10 0)\n ;=> #(0 -1 -2 -3 -4 -5 -6 -7 -8 -9)") (p "Construct a vector of the sequence of integers in the range [0,n).") (highlight scheme "(vector-unfold values n)\n ;=> #(0 1 2 ... n-2 n-1)") (p "Copy vector.") (highlight scheme "(vector-unfold (lambda (i) (vector-ref vector i))\n                 (vector-length vector))"))
(def (sig (procedure "(vector-unfold-right f length initial-seed ...)" (id vector-unfold-right))) (p "Like " (tt "vector-unfold") ", but it uses " (tt "f") " to generate elements from right-to-left, rather than left-to-right. The first index used is length - 1. Note that the termination condition is different from the " (tt "unfold-right") " procedure of SRFI 1.") (p "Examples:") (p "Construct a vector of pairs of non-negative integers whose values sum to 4.") (highlight scheme "(vector-unfold-right (lambda (i x) (values (cons i x) (+ x 1))) 5 0)\n ;=> #((0 . 4) (1 . 3) (2 . 2) (3 . 1) (4 . 0))") (p "Reverse vector.") (highlight scheme "(vector-unfold-right (lambda (i x) (values (vector-ref vector x) (+ x 1)))\n                       (vector-length vector)\n                       0)"))
(def (sig (procedure "(vector-copy vec [start [end]])" (id vector-copy))) (p "[R7RS-small] Allocates a new vector whose length is " (tt "end") " - " (tt "start") " and fills it with elements from " (tt "vec") ", taking elements from " (tt "vec") " starting at index " (tt "start") " and stopping at index " (tt "end") ". " (tt "start") " defaults to 0 and " (tt "end") " defaults to the value of " (tt "(vector-length vec)") ". SRFI 43 provides an optional fill argument to supply values if end is greater than the length of " (tt "vec") ". Neither R7RS-small nor this SRFI requires support for this argument.") (p "Examples:") (highlight scheme "(vector-copy '#(a b c d e f g h i))\n ;=> #(a b c d e f g h i)\n\n(vector-copy '#(a b c d e f g h i) 6)\n ;=> #(g h i)\n\n(vector-copy '#(a b c d e f g h i) 3 6)\n ;=> #(d e f)"))
(def (sig (procedure "(vector-reverse-copy vec [start [end]])" (id vector-reverse-copy))) (p "Like " (tt "vector-copy") ", but it copies the elements in the reverse order from " (tt "vec") ".") (p "Example:") (highlight scheme "(vector-reverse-copy '#(5 4 3 2 1 0) 1 5)\n ;=> #(1 2 3 4)"))
(def (sig (procedure "(vector-append vec ...)" (id vector-append))) (p "[R7RS-small] Returns a newly allocated vector that contains all elements in order from the subsequent locations in " (tt "vec ...") ".") (p "Examples:") (highlight scheme "(vector-append '#(x) '#(y))\n ;=> #(x y)\n\n(vector-append '#(a) '#(b c d))\n ;=> #(a b c d)\n\n(vector-append '#(a #(b)) '#(#(c)))\n ;=> #(a #(b) #(c))"))
(def (sig (procedure "(vector-concatenate list-of-vectors)" (id vector-concatenate))) (p "Appends each vector in list-of-vectors. This is equivalent to:") (highlight scheme "(apply vector-append list-of-vectors)") (p "However, it may be implemented better.") (p "Example:") (highlight scheme "(vector-concatenate '(#(a b) #(c d)))\n ;=> #(a b c d)"))
(def (sig (procedure "(vector-append-subvectors [vec start end] ...)" (id vector-append-subvectors))) (p "Returns a vector that contains every element of each " (tt "vec") " from " (tt "start") " to " (tt "end") " in the specified order. This procedure is a generalization of " (tt "vector-append") ".") (p "Example:") (highlight scheme "(vector-append-subvectors '#(a b c d e) 0 2 '#(f g h i j) 2 4)\n ;=> #(a b h i)"))
(def (sig (procedure "(vector? x)" (id vector?))) (p "[R7RS-small] Disjoint type predicate for vectors: this returns " (tt "#t") " if " (tt "x") " is a vector, and " (tt "#f") " if otherwise.") (p "Examples:") (highlight scheme "(vector? '#(a b c)) ;=> #t\n(vector? '(a b c))  ;=> #f\n(vector? #t)        ;=> #f\n(vector? '#())      ;=> #t\n(vector? '())       ;=> #f"))
(def (sig (procedure "(vector-empty? vec)" (id vector-empty?))) (p "Returns " (tt "#t") " if vec is empty, i.e. its length is 0, and " (tt "#f") " if not.") (p "Examples:") (highlight scheme "(vector-empty? '#(a))   ;=> #f\n(vector-empty? '#(()))  ;=> #f\n(vector-empty? '#(#())) ;=> #f\n(vector-empty? '#())    ;=> #t"))
(def (sig (procedure "(vector= elt=? vec ...)" (id vector=))) (p "Vector structure comparator, generalized across user-specified element comparators. Vectors a and b are considered equal by " (tt "vector=") " iff their lengths are the same, and for each respective element Ea and Eb, " (tt "(elt=? Ea Eb)") " returns a true value. " (tt "elt=?") " is always applied to two arguments. Element comparison must be consistent with eq; that is, if " (tt "(eq? Ea Eb)") " results in a true value, then " (tt "(elt=? Ea Eb)") " must also result in a true value. This may be exploited to avoid unnecessary element comparisons. (The reference implementation does, but it does not consider the situation where " (tt "elt=?") " is in fact itself " (tt "eq?") " to avoid yet more unnecessary comparisons.)") (p "If there are only zero or one vector arguments, " (tt "#t") " is automatically returned.  The dynamic order in which comparisons of elements and of vectors are performed is left completely unspecified; do not rely on a particular order.") (p "Examples:") (highlight scheme "(vector= eq? '#(a b c d) '#(a b c d)) ;=> #t\n(vector= eq? '#(a b c d) '#(a b d c)) ;=> #f\n(vector= = '#(1 2 3 4 5) '#(1 2 3 4)) ;=> #f\n(vector= = '#(1 2 3 4) '#(1 2 3 4))   ;=> #t") (p "The two trivial cases.") (highlight scheme "(vector= eq?) ;=> #t\n(vector= eq? '#(a)) ;=> #t") (p "Note the fact that we don't use vector literals in the next two -- it is unspecified whether or not literal vectors with the same external representation are " (tt "eq?") ".") (highlight scheme "(vector= eq? (vector (vector 'a)) (vector (vector 'a)))\n ;=> #f\n(vector= equal? (vector (vector 'a)) (vector (vector 'a)))\n ;=> #t"))
(def (sig (procedure "(vector-ref vec i)" (id vector-ref))) (p "[R7RS-small] Vector element dereferencing: returns the value that the location in " (tt "vec") " at " (tt "i") " is mapped to in the store. Indexing is based on zero. " (tt "i") " must be within the range " (tt "[0, (vector-length vec))") ".") (p "Example:") (highlight scheme "(vector-ref '#(a b c d) 2) ;=> c"))
(def (sig (procedure "(vector-length vec)" (id vector-length))) (p "[R7RS-small] Returns the length of " (tt "vec") ", the number of locations reachable from " (tt "vec") ". (The careful word 'reachable' is used to allow for 'vector slices,' whereby " (tt "vec") " refers to a larger vector that contains more locations that are unreachable from " (tt "vec") ". This SRFI does not define vector slices, but later SRFIs may.)") (p "Example:") (highlight scheme "(vector-length '#(a b c)) ;=> 3"))
(def (sig (procedure "(vector-fold kons knil vec1 vec2 ...)" (id vector-fold))) (p "The fundamental vector iterator. " (tt "kons") " is iterated over each value in all of the vectors, stopping at the end of the shortest; " (tt "kons") " is applied as " (tt "(kons state (vector-ref vec1 i) (vector-ref vec2 i) ...)") " where state is the current state value -- the current state value begins with " (tt "knil") ", and becomes whatever " (tt "kons") " returned on the previous iteration --, and i is the current index.") (p "The iteration is strictly left-to-right.") (p "Examples:") (p "Find the longest string's length in vector-of-strings.") (highlight scheme "(vector-fold (lambda (len str) (max (string-length str) len))\n               0 vector-of-strings)") (p "Produce a list of the reversed elements of vec.") (highlight scheme "(vector-fold (lambda (tail elt) (cons elt tail))\n               '() vec)") (p "Count the number of even numbers in vec.") (highlight scheme "(vector-fold (lambda (counter n)\n                 (if (even? n) (+ counter 1) counter))\n               0 vec)"))
(def (sig (procedure "(vector-fold-right kons knil vec1 vec2 ...)" (id vector-fold-right))) (p "Similar to " (tt "vector-fold") ", but it iterates right to left instead of left to right.") (p "Example:") (p "Convert a vector to a list.") (highlight scheme "(vector-fold-right (lambda (tail elt) (cons elt tail))\n                     '() '#(a b c d))\n ;=> (a b c d)"))
(def (sig (procedure "(vector-map f vec1 vec2 ...)" (id vector-map))) (p "[R7RS-small] Constructs a new vector of the shortest size of the vector arguments. Each element at index i of the new vector is mapped from the old vectors by " (tt "(f (vector-ref vec1 i) (vector-ref vec2 i) ...)") ". The dynamic order of application of " (tt "f") " is unspecified.") (p "Examples:") (highlight scheme "(vector-map (lambda (x) (* x x))\n              (vector-unfold (lambda (i x) (values x (+ x 1))) 4 1))\n ;=> #(1 4 9 16)\n\n(vector-map (lambda (x y) (* x y))\n              (vector-unfold (lambda (x) (values x (+ x 1))) 5 1)\n              (vector-unfold (lambda (x) (values x (- x 1))) 5 5))\n ;=> #(5 8 9 8 5)\n\n(let ((count 0))\n   (vector-map (lambda (ignored-elt)\n                 (set! count (+ count 1))\n                 count)\n               '#(a b)))\n ;=> #(1 2) OR #(2 1)"))
(def (sig (procedure "(vector-map! f vec1 vec2 ...)" (id vector-map!))) (p "Similar to " (tt "vector-map") ", but rather than mapping the new elements into a new vector, the new mapped elements are destructively inserted into " (tt "vec1") ". Again, the dynamic order of application of " (tt "f") " unspecified, so it is dangerous for " (tt "f") " to apply either " (tt "vector-ref") " or " (tt "vector-set!") " to " (tt "vec1") " in " (tt "f") "."))
(def (sig (procedure "(vector-for-each f vec1 vec2 ...)" (id vector-for-each))) (p "[R7RS-small] Simple vector iterator: applies " (tt "f") " to the corresponding list of parallel elements from " (tt "vec1 vec2 ...") " in the range [0, length), where length is the length of the smallest vector argument passed, In contrast with " (tt "vector-map") ", " (tt "f") " is reliably applied to each subsequent element, starting at index 0, in the vectors.") (p "Example:") (highlight scheme "(vector-for-each (lambda (x) (display x) (newline))\n                 '#(\"foo\" \"bar\" \"baz\" \"quux\" \"zot\"))") (p "Displays:") (p "foo bar baz quux zot"))
(def (sig (procedure "(vector-count pred? vec1 vec2 ...)" (id vector-count))) (p "Counts the number of parallel elements in the vectors that satisfy " (tt "pred?") ", which is applied, for each index i in the range [0, length) where length is the length of the smallest vector argument, to each parallel element in the vectors, in order.") (p "Examples:") (highlight scheme "(vector-count even? '#(3 1 4 1 5 9 2 5 6))\n ;=> 3\n\n(vector-count < '#(1 3 6 9) '#(2 4 6 8 10 12))\n ;=> 2"))
(def (sig (procedure "(vector-cumulate f knil vec)" (id vector-cumulate))) (p "Returns a newly allocated vector new with the same length as " (tt "vec") ". Each element i of new is set to the result of invoking " (tt "f") " on newi-1 and " (tt "veci") ", except that for the first call on " (tt "f") ", the first argument is " (tt "knil") ". The new vector is returned.") (p "Example:") (highlight scheme "(vector-cumulate + 0 '#(3 1 4 1 5 9 2 5 6))\n ;=> #(3 4 8 9 14 23 25 30 36)"))
(def (sig (procedure "(vector-index pred? vec1 vec2 ...)" (id vector-index))) (p "Finds & returns the index of the first elements in " (tt "vec1 vec2 ...") " that satisfy " (tt "pred?") ". If no matching element is found by the end of the shortest vector, " (tt "#f") " is returned.") (p "Examples:") (highlight scheme "(vector-index even? '#(3 1 4 1 5 9))                 ;=> 2\n(vector-index < '#(3 1 4 1 5 9 2 5 6) '#(2 7 1 8 2)) ;=> 1\n(vector-index = '#(3 1 4 1 5 9 2 5 6) '#(2 7 1 8 2)) ;=> #f"))
(def (sig (procedure "(vector-index-right pred? vec1 vec2 ...)" (id vector-index-right))) (p "Like " (tt "vector-index") ", but it searches right-to-left, rather than left-to-right, and all of the vectors must have the same length."))
(def (sig (procedure "(vector-skip pred? vec1 vec2 ...)" (id vector-skip))) (p "Finds & returns the index of the first elements in " (tt "vec1 vec2 ...") " that do not satisfy " (tt "pred?") ". If all the values in the vectors satisfy " (tt "pred?") " until the end of the shortest vector, this returns " (tt "#f") ". This is equivalent to:") (highlight scheme "(vector-index (lambda (x1 x2 ...) (not (pred? x1 x1 ...)))\n                    vec1 vec2 ...)") (p "Example:") (highlight scheme "(vector-skip number? '#(1 2 a b 3 4 c d))\n ;=> 2"))
(def (sig (procedure "(vector-skip-right pred? vec1 vec2 ...)" (id vector-skip-right))) (p "Like " (tt "vector-skip") ", but it searches for a non-matching element right-to-left, rather than left-to-right, and it is an error if all of the vectors do not have the same length. This is equivalent to:") (highlight scheme "(vector-index-right (lambda (x1 x2 ...) (not (pred? x1 x1 ...)))\n                          vec1 vec2 ...)"))
(def (sig (procedure "(vector-binary-search vec value cmp)" (id vector-binary-search))) (p "Similar to " (tt "vector-index") " and " (tt "vector-index-right") ", but instead of searching left to right or right to left, this performs a binary search. If there is more than one element of " (tt "vec") " that matches value in the sense of " (tt "cmp") ", " (tt "vector-binary-search") " may return the index of any of them.") (p (tt "cmp") " should be a procedure of two arguments and return a negative integer, which indicates that its first argument is less than its second, zero, which indicates that they are equal, or a positive integer, which indicates that the first argument is greater than the second argument. An example " (tt "cmp") " might be:") (highlight scheme "(lambda (char1 char2)\n  (cond ((char<? char1 char2) -1)\n        ((char=? char1 char2) 0)\n        (else 1)))"))
(def (sig (procedure "(vector-any pred? vec1 vec2 ...)" (id vector-any))) (p "Finds the first set of elements in parallel from " (tt "vec1 vec2 ...") " for which " (tt "pred?") " returns a true value. If such a parallel set of elements exists, " (tt "vector-any") " returns the value that " (tt "pred?") " returned for that set of elements. The iteration is strictly left-to-right."))
(def (sig (procedure "(vector-every pred? vec1 vec2 ...)" (id vector-every))) (p "If, for every index i between 0 and the length of the shortest vector argument, the set of elements " (tt "(vector-ref vec1 i) (vector-ref vec2 i) ...") " satisfies " (tt "pred?") ", " (tt "vector-every") " returns the value that " (tt "pred?") " returned for the last set of elements, at the last index of the shortest vector. The iteration is strictly left-to-right."))
(def (sig (procedure "(vector-partition pred? vec)" (id vector-partition))) (p "A vector the same size as " (tt "vec") " is newly allocated and filled with all the elements of " (tt "vec") " that satisfy pred? in their original order followed by all the elements that do not satisfy " (tt "pred") ", also in their original order.") (p "Two values are returned, the newly allocated vector and the index of the leftmost element that does not satisfy " (tt "pred") "."))
(def (sig (procedure "(vector-set! vec i value)" (id vector-set!))) (p "[R7RS-small] Assigns the contents of the location at i in " (tt "vec") " to value."))
(def (sig (procedure "(vector-swap! vec i j)" (id vector-swap!))) (p "Swaps or exchanges the values of the locations in " (tt "vec") " at i & j."))
(def (sig (procedure "(vector-fill! vec fill [start [end]])" (id vector-fill!))) (p "[R7RS-small] Assigns the value of every location in " (tt "vec") " between " (tt "start") ", which defaults to 0 and " (tt "end") ", which defaults to the length of " (tt "vec") ", to " (tt "fill") "."))
(def (sig (procedure "(vector-reverse! vec [start [end]])" (id vector-reverse!))) (p "Destructively reverses the contents of the sequence of locations in " (tt "vec") " between " (tt "start") " and " (tt "end") ". Start defaults to 0 and end defaults to the length of " (tt "vec") ". Note that this does not deeply reverse."))
(def (sig (procedure "(vector-copy! to at from [start [end]])" (id vector-copy!))) (p "[R7RS-small] Copies the elements of vector " (tt "from") " between " (tt "start") " and " (tt "end") " to vector " (tt "to") ", starting at " (tt "at") ". The order in which elements are copied is unspecified, except that if the source and destination overlap, copying takes place as if the source is first copied into a temporary vector and then into the destination. This can be achieved without allocating storage by making sure to copy in the correct direction in such circumstances."))
(def (sig (procedure "(vector-reverse-copy! to at from [start [end]])" (id vector-reverse-copy!))) (p "Like " (tt "vector-copy!") ", but the elements appear in " (tt "to") " in reverse order. " (tt "(vector-reverse! target tstart send)") " would."))
(def (sig (procedure "(vector-unfold! f vec start end initial-seed ...)" (id vector-unfold!))) (p "Like " (tt "vector-unfold") ", but the elements are copied into the vector " (tt "vec") " starting at element " (tt "start") " rather than into a newly allocated vector. Terminates when " (tt "end - start") " elements have been generated."))
(def (sig (procedure "(vector-unfold-right! f vec start end initial-seed ...)" (id vector-unfold-right!))) (p "Like " (tt "vector-unfold!") ", but the elements are copied in reverse order into the vector " (tt "vec") " starting at the index preceding " (tt "end") "."))
(def (sig (procedure "(vector->list vec [start [end]])" (id vector->list))) (p "[R7RS-small] Creates a list containing the elements in " (tt "vec") " between " (tt "start") ", which defaults to 0, and " (tt "end") ", which defaults to the length of " (tt "vec") "."))
(def (sig (procedure "(reverse-vector->list vec [start [end]])" (id reverse-vector->list))) (p "Like " (tt "vector->list") ", but the resulting list contains the elements in reverse of " (tt "vector") "."))
(def (sig (procedure "(list->vector proper-list)" (id list->vector))) (p "[R7RS-small] Creates a vector of elements from proper-list."))
(def (sig (procedure "(reverse-list->vector proper-list)" (id reverse-list->vector))) (p "Like " (tt "list->vector") ", but the resulting vector contains the elements in reverse of proper-list."))
(def (sig (procedure "(string->vector string [start [end]])" (id string->vector))) (p "[R7RS-small] Creates a vector containing the elements in " (tt "string") " between " (tt "start") ", which defaults to 0, and " (tt "end") ", which defaults to the length of " (tt "string") "."))
(def (sig (procedure "(vector->string vec [start [end]])" (id vector->string))) (p "[R7RS-small] Creates a string containing the elements in " (tt "vec") " between " (tt "start") ", which defaults to 0, and " (tt "end") ", which defaults to the length of " (tt "vec") ". It is an error if the elements are not characters."))
