(index ("vector-unfold" 0) ("vector-unfold-right" 1003) ("vector-copy" 1621) ("vector-reverse-copy" 2568) ("vector-append" 2856) ("vector-concatenate" 3259) ("vector-empty?" 3606) ("vector=" 3975) ("vector-fold" 5761) ("vector-fold-right" 6896) ("vector-map" 7268) ("vector-map!" 8245) ("vector-for-each" 8718) ("vector-count" 9419) ("vector-index" 10089) ("vector-index-right" 10631) ("vector-skip" 10916) ("vector-skip-right" 11497) ("vector-binary-search" 11949) ("vector-any" 12687) ("vector-every" 13097) ("vector-swap!" 13587) ("vector-fill!" 13772) ("vector-reverse!" 14092) ("vector-copy!" 14467) ("vector-reverse-copy!" 15067) ("vector->list" 15541) ("reverse-vector->list" 15840) ("list->vector" 16073) ("reverse-list->vector" 16602))
(def (sig (procedure "(vector-unfold f length initial-seed ···) -> vector" (id vector-unfold))) (p "The fundamental vector constructor. Creates a vector whose length is " (tt "length") " and iterates across each index " (tt "k") " between " (tt "0") " and " (tt "length") ", applying " (tt "f") " at each iteration to the current index and current seeds, in that order, to receive " (tt "n + 1") " values: first, the element to put in the " (tt "k") "th slot of the new vector and " (tt "n") " new seeds for the next iteration. It is an error for the number of seeds to vary between iterations.") (p "Examples:") (pre "(vector-unfold (λ (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," (tt "n") ").") (pre "(vector-unfold values n)\n  ;=> #(0 1 2 ··· n-2 n-1)") (p "Copy " (tt "vector") ".") (pre "(vector-unfold (λ (i) (vector-ref vector i))\n               (vector-length vector))"))
(def (sig (procedure "(vector-unfold-right f length initial-seed ···) -> vector" (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.") (p "Examples:") (p "Construct a vector in reverse of the integers in the range [0," (tt "n") ").") (pre "(vector-unfold-right (λ (i x) (values x (+ x 1)))\n                     n 0)\n  ;=> #(n-1 n-2 ··· 2 1 0)") (p "Reverse " (tt "vector") ".") (pre "(vector-unfold-right (λ (i x) (values (vector-ref vector x) (+ x 1)))\n                     (vector-length vector) 0)"))
(def (sig (procedure "(vector-copy vec [start [end [fill]]]) -> vector" (id vector-copy))) (p "Allocates a new vector whose length is " (tt "end - 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 " (tt "0") " and " (tt "end") " defaults to the value of " (tt "(vector-length vec)") ". If " (tt "end") " extends beyond the length of " (tt "vec") ", the slots in the new vector that obviously cannot be filled by elements from " (tt "vec") " are filled with " (tt "fill") ", whose default value is unspecified.") (p "Examples:") (pre "(vector-copy '#(a b c d e f g h i))\n  ;=> #(a b c d e f g h i)") (pre "(vector-copy '#(a b c d e f g h i) 6)\n  ;=> #(g h i)") (pre "(vector-copy '#(a b c d e f g h i) 3 6)\n  ;=> #(d e f)") (pre "(vector-copy '#(a b c d e f g h i) 6 12 'x)\n  ;=> #(g h i x x x)"))
(def (sig (procedure "(vector-reverse-copy vec [start [end]]) -> vector" (id vector-reverse-copy))) (p "Like " (tt "vector-copy") ", but it copies the elements in the reverse order from " (tt "vec") ".") (p "Example:") (pre "(vector-reverse-copy '#(5 4 3 2 1 0) 1 5)\n  ;=> #(1 2 3 4)"))
(def (sig (procedure "(vector-append vec ···) -> vector" (id vector-append))) (p "Returns a newly allocated vector that contains all elements in order from the subsequent locations in " (tt "vec ···") ".") (p "Examples:") (pre "(vector-append '#(x) '#(y))\n  ;=> #(x y)") (pre "(vector-append '#(a) '#(b c d))\n  ;=> #(a b c d)") (pre "(vector-append '#(a #(b)) '#(#(c)))\n  ;=> #(a #(b) #(c))"))
(def (sig (procedure "(vector-concatenate list-of-vectors) -> vector" (id vector-concatenate))) (p "Appends each vector in " (tt "list-of-vectors") ". This is equivalent to:") (pre "(apply vector-append list-of-vectors)") (p "However, it may be implemented better.") (p "Example:") (pre "(vector-concatenate '(#(a b) #(c d)))\n  ;=> #(a b c d)"))
(def (sig (procedure "(vector-empty? vec) -> boolean" (id vector-empty?))) (p "Returns " (tt "#t") " if " (tt "vec") " is empty, i.e. its length is " (tt "0") ", and " (tt "#f") " if not.") (p "Examples:") (pre "(vector-empty? '#(a))\n  ;=> #f") (pre "(vector-empty? '#(()))\n  ;=> #f") (pre "(vector-empty? '#(#()))\n  ;=> #f") (pre "(vector-empty? '#())\n  ;=> #t"))
(def (sig (procedure "(vector= elt=? vec ···) -> boolean" (id vector=))) (p "Vector structure comparator, generalized across user-specified element comparators. Vectors " (tt "a") " and " (tt "b") " are considered equal by " (tt "vector=") " iff their lengths are the same, and for each respective elements " (tt "E_a") " and " (tt "E_b") ", " (tt "(elt=? E_a E_b)") " returns a true value. " (tt "Elt=?") " is always applied to two arguments. Element comparison must be consistent with " (tt "eq") "; that is, if " (tt "(eq? E_a E_b)") " results in a true value, then " (tt "(elt=? E_a E_b)") " 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:") (pre "(vector= eq? '#(a b c d) '#(a b c d))\n  ;=> #t") (pre "(vector= eq? '#(a b c d) '#(a b d c))\n  ;=> #f") (pre "(vector= = '#(1 2 3 4 5) '#(1 2 3 4))\n  ;=> #f") (pre "(vector= = '#(1 2 3 4) '#(1 2 3 4))\n  ;=> #t") (p "The two trivial cases.") (pre "(vector= eq?)\n  ;=> #t") (pre "(vector= eq? '#(a))\n  ;=> #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?") ".") (pre "(vector= eq? (vector (vector 'a)) (vector (vector 'a)))\n  ;=> #f") (pre "(vector= equal? (vector (vector 'a)) (vector (vector 'a)))\n  ;=> #t"))
(def (sig (procedure "(vector-fold kons knil vec_1 vec_2 ···) -> value" (id vector-fold))) (p "The fundamental vector iterator. " (tt "Kons") " is iterated over each index in all of the vectors, stopping at the end of the shortest; " (tt "kons") " is applied as " (tt " (kons i state (vector-ref vec_1 i) (vector-ref vec_2 i) ···) ") " where " (tt "state") " is the current state value — the current state value begins with " (tt "knil") ", and becomes whatever " (tt "kons") " returned at the respective iteration —, and " (tt "i") " is the current index.") (p "The iteration is strictly left-to-right.") (p "Examples:") (p "Find the longest string's length in " (tt "vector-of-strings") ".") (pre "(vector-fold (λ (index len str) (max (string-length str) len))\n             0 vector-of-strings)") (p "Produce a list of the reversed elements of " (tt "vec") ".") (pre "(vector-fold (λ (index tail elt) (cons elt tail))\n             '() vec)") (p "Count the number of even numbers in " (tt "vec") ".") (pre "(vector-fold (λ (index counter n)\n               (if (even? n) (+ counter 1) counter))\n             0 vec)"))
(def (sig (procedure "(vector-fold-right kons knil vec_1 vec_2 ···) -> value" (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.") (pre "(vector-fold-right (λ (index tail elt) (cons elt tail))\n                   '() '#(a b c d))\n  ;=> (a b c d)"))
(def (sig (procedure "(vector-map f vec_1 vec_2 ···) -> vector" (id vector-map))) (p "Constructs a new vector of the shortest size of the vector arguments. Each element at index " (tt "i") " of the new vector is mapped from the old vectors by " (tt "(f i (vector-ref vec_1 i) (vector-ref vec_2 i) ···)") ". The dynamic order of application of " (tt "f") " is unspecified.") (p "Examples:") (pre "(vector-map (λ (i x) (* x x))\n            (vector-unfold (λ (i x) (values x (+ x 1))) 4 1))\n  ;=> #(1 4 9 16)") (pre "(vector-map (λ (i x y) (* x y))\n            (vector-unfold (λ (i x) (values x (+ x 1))) 5 1)\n            (vector-unfold (λ (i x) (values x (- x 1))) 5 5))\n  ;=> #(5 8 9 8 5)") (pre "(let ((count 0))\n (vector-map (λ (ignored-index ignored-elt)\n               (set! count (+ count 1))\n               count)\n             '#(a b)))\n  ;=> #(1 2) OR #(2 1)") (pre "(vector-map (λ (i elt) (+ i elt))\n            '#(1 2 3 4))\n  ;=> #(1 3 5 7)"))
(def (sig (procedure "(vector-map! f vec_1 vec_2 ···) -> unspecified" (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 "vec_1") ". 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 "vec_1") " in " (tt "f") "."))
(def (sig (procedure "(vector-for-each f vec_1 vec_2 ···) -> unspecified" (id vector-for-each))) (p "Simple vector iterator: applies " (tt "f") " to each index in the range [0, " (tt "length") "), where " (tt "length") " is the length of the smallest vector argument passed, and the respective list of parallel elements from " (tt "vec_1 vec_2 ···") " at that index. In contrast with " (tt "vector-map") ", " (tt "f") " is reliably applied to each subsequent elements, starting at index 0, in the vectors.") (p "Example:") (pre "(vector-for-each (λ (i x) (display x) (newline))\n                 '#(\"foo\" \"bar\" \"baz\" \"quux\" \"zot\"))") (p "Displays:") (pre "foo\nbar\nbaz\nquux\nzot"))
(def (sig (procedure "(vector-count pred? vec_1 vec_2 ···) -> exact nonnegative integer" (id vector-count))) (p "Counts the number of parallel elements in the vectors that satisfy " (tt "pred?") ", which is applied, for each index " (tt "i") " in the range [0, " (tt "length") ") — where " (tt "length") " is the length of the smallest vector argument —, to " (tt "i") " and each parallel element in the vectors at that index, in order.") (p "Examples:") (pre "(vector-count (λ (i elt) (even? elt))\n              '#(3 1 4 1 5 9 2 5 6))\n  ;=> 3") (pre "(vector-count (λ (i x y) (< x y))\n              '#(1 3 6 9)\n              '#(2 4 6 8 10 12))\n  ;=> 2"))
(def (sig (procedure "(vector-index pred? vec_1 vec_2 ···) -> exact nonnegative integer or #f" (id vector-index))) (p "Finds & returns the index of the first elements in " (tt "vec_1 vec_2 ···") " that satisfy " (tt "pred?") ". If no matching element is found by the end of the shortest vector, " (tt "#f") " is returned.") (p "Examples:") (pre "(vector-index even? '#(3 1 4 1 5 9))\n  ;=> 2") (pre "(vector-index < '#(3 1 4 1 5 9 2 5 6) '#(2 7 1 8 2))\n  ;=> 1") (pre "(vector-index = '#(3 1 4 1 5 9 2 5 6) '#(2 7 1 8 2))\n  ;=> #f"))
(def (sig (procedure "(vector-index-right pred? vec_1 vec_2 ···) -> exact nonnegative integer or #f" (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 " (i "must") " have the same length."))
(def (sig (procedure "(vector-skip pred? vec_1 vec_2 ···) -> exact nonnegative integer or #f" (id vector-skip))) (p "Finds & returns the index of the first elements in " (tt "vec_1 vec_2 ···") " that do " (i "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:") (pre "(vector-index (λ (x_1 x_2 ···) (not (pred? x_1 x_1 ···)))\n              vec_1 vec_2 ···)") (p "Example:") (pre "(vector-skip number? '#(1 2 a b 3 4 c d))\n  ;=> 2"))
(def (sig (procedure "(vector-skip-right pred? vec_1 vec_2 ···) -> exact nonnegative integer or #f" (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 all of the vectors " (i "must") " have the same length. This is equivalent to:") (pre "(vector-index-right (λ (x_1 x_2 ···) (not (pred? x_1 x_1 ···)))\n                    vec_1 vec_2 ···)"))
(def (sig (procedure "(vector-binary-search vec value cmp) -> exact nonnegative integer or #f" (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. " (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:") (pre "(λ (char_1 char_2)\n  (cond ((char<? char_1 char_2) -1)\n        ((char=? char_1 char_2) 0)\n        (else 1)))"))
(def (sig (procedure "(vector-any pred? vec_1 vec_2 ···) -> value or #f" (id vector-any))) (p "Finds the first set of elements in parallel from " (tt "vec_1 vec_2 ···") " 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? vec_1 vec_2 ···) -> value or #f" (id vector-every))) (p "If, for every index " (tt "i") " between 0 and the length of the shortest vector argument, the set of elements " (tt "(vector-ref vec_1 i) (vector-ref vec_2 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-swap! vec i j) -> unspecified" (id vector-swap!))) (p "Swaps or exchanges the values of the locations in " (tt "vec") " at " (tt "i") " & " (tt "j") "."))
(def (sig (procedure "(vector-fill! vec fill [start [end]]) -> unspecified" (id vector-fill!))) (p "[" (i "R5RS") "+] Assigns the value of every location in " (tt "vec") " between " (tt "start") ", which defaults to " (tt "0") " and " (tt "end") ", which defaults to the length of " (tt "vec") ", to " (tt "fill") "."))
(def (sig (procedure "(vector-reverse! vec [start [end]]) -> unspecified" (id vector-reverse!))) (p "Destructively reverses the contents of the sequence of locations in " (tt "vec") " between " (tt "start") " and " (tt "end") ". " (tt "Start") " defaults to " (tt "0") " and " (tt "end") " defaults to the length of " (tt "vec") ". Note that this does not deeply reverse."))
(def (sig (procedure "(vector-copy! target tstart source [sstart [send]]) -> unspecified" (id vector-copy!))) (p "Copies a block of elements from " (tt "source") " to " (tt "target") ", both of which must be vectors, starting in " (tt "target") " at " (tt "tstart") " and starting in " (tt "source") " at " (tt "sstart") ", ending when " (tt "send - sstart") " elements have been copied. It is an error for " (tt "target") " to have a length less than " (tt "tstart + (send - sstart)") ". " (tt "Sstart") " defaults to " (tt "0") " and " (tt "send") " defaults to the length of " (tt "source") "."))
(def (sig (procedure "(vector-reverse-copy! target tstart source [sstart [send]]) -> unspecified" (id vector-reverse-copy!))) (p "Like " (tt "vector-copy!") ", but this copies the elements in the reverse order. It is an error if " (tt "target") " and " (tt "source") " are identical vectors and the target & source ranges overlap; however, if " (tt "tstart = sstart") ", " (tt "vector-reverse-copy!") " behaves as " (tt " (vector-reverse! target tstart send) ") " would."))
(def (sig (procedure "(vector->list vec [start [end]]) -> proper-list" (id vector->list))) (p "[" (i "R5RS") "+] Creates a list containing the elements in " (tt "vec") " between " (tt "start") ", which defaults to " (tt "0") ", and " (tt "end") ", which defaults to the length of " (tt "vec") "."))
(def (sig (procedure "(reverse-vector->list vec [start [end]]) -> proper-list" (id reverse-vector->list))) (p "Like " (tt "vector->list") ", but the resulting list contains the elements in reverse between the the specified range."))
(def (sig (procedure "(list->vector proper-list [start [end]])" (id list->vector))) (p "[" (i "R5RS") "+] Produce a vector containing the elements in " (tt "proper-list") ", which must be a proper list, between " (tt "start") ", whose default is 0, and " (tt "end") ", whose default is the length of " (tt "list") ".  It is suggested that if the length of " (tt "list") " is known in advance, the " (tt "start") " and " (tt "end") " arguments be passed, so that " (tt "list->vector") " need not call " (tt "length") " itself."))
(def (sig (procedure "(reverse-list->vector proper-list [start [end]]) -> vector" (id reverse-list->vector))) (p "Like " (tt "list->vector") ", but the resulting list contains the elements in reverse of " (tt "proper-list") "."))
