From b752370a57d9de105452df9656440c22f286cb58 Mon Sep 17 00:00:00 2001 From: Sam Tobin-Hochstadt Date: Mon, 3 May 2010 17:13:14 -0400 Subject: [PATCH] use @racket instead of @scheme in vector docs --- collects/scribblings/reference/vectors.scrbl | 162 +++++++++---------- 1 file changed, 81 insertions(+), 81 deletions(-) diff --git a/collects/scribblings/reference/vectors.scrbl b/collects/scribblings/reference/vectors.scrbl index 845f3058b6..46e4352742 100644 --- a/collects/scribblings/reference/vectors.scrbl +++ b/collects/scribblings/reference/vectors.scrbl @@ -6,38 +6,38 @@ @guideintro["vectors"]{vectors} A @deftech{vector} is a fixed-length array with constant-time access -and update of the vector slots, which are numbered from @scheme[0] to +and update of the vector slots, which are numbered from @racket[0] to one less than the number of slots in the vector. -Two vectors are @scheme[equal?] if they have the same length, and if +Two vectors are @racket[equal?] if they have the same length, and if the values in corresponding slots of the vectors are -@scheme[equal?]. +@racket[equal?]. A vector can be @defterm{mutable} or @defterm{immutable}. When an -immutable vector is provided to a procedure like @scheme[vector-set!], +immutable vector is provided to a procedure like @racket[vector-set!], the @exnraise[exn:fail:contract]. Vectors generated by the default reader (see @secref["parse-string"]) are immutable. A vector can be used as a single-valued sequence (see @secref["sequences"]). The elements of the vector serve as elements -of the sequence. See also @scheme[in-vector]. +of the sequence. See also @racket[in-vector]. @defproc[(vector? [v any/c]) boolean?]{ -Returns @scheme[#t] if @scheme[v] is a vector, @scheme[#f] otherwise.} +Returns @racket[#t] if @racket[v] is a vector, @racket[#f] otherwise.} @defproc[(make-vector [size exact-nonnegative-integer?] [v any/c 0]) vector?]{ -Returns a mutable vector with @scheme[size] slots, where all slots are -initialized to contain @scheme[v].} +Returns a mutable vector with @racket[size] slots, where all slots are +initialized to contain @racket[v].} @defproc[(vector [v any/c] ...) vector?]{ -Returns a newly allocated mutable vector with as many slots as provided @scheme[v]s, -where the slots are initialized to contain the given @scheme[v]s in +Returns a newly allocated mutable vector with as many slots as provided @racket[v]s, +where the slots are initialized to contain the given @racket[v]s in order.} @@ -45,55 +45,55 @@ order.} immutable?)]{ Returns a newly allocated immutable vector with as many slots as provided -@scheme[v]s, where the slots are contain the given @scheme[v]s in +@racket[v]s, where the slots are contain the given @racket[v]s in order.} @defproc[(vector-length [vec vector?]) exact-nonnegative-integer?]{ -Returns the length of @scheme[vec] (i.e., the number of slots in the +Returns the length of @racket[vec] (i.e., the number of slots in the vector).} @defproc[(vector-ref [vec vector?][pos exact-nonnegative-integer?]) any/c]{ -Returns the element in slot @scheme[pos] of @scheme[vec]. The first -slot is position @scheme[0], and the last slot is one less than -@scheme[(vector-length vec)].} +Returns the element in slot @racket[pos] of @racket[vec]. The first +slot is position @racket[0], and the last slot is one less than +@racket[(vector-length vec)].} @defproc[(vector-set! [vec (and/c vector? (not/c immutable?))] [pos exact-nonnegative-integer?] [v any/c]) void?]{ -Updates the slot @scheme[pos] of @scheme[vec] to contain @scheme[v].} +Updates the slot @racket[pos] of @racket[vec] to contain @racket[v].} @defproc[(vector->list [vec vector?]) list?]{ -Returns a list with the same length and elements as @scheme[vec].} +Returns a list with the same length and elements as @racket[vec].} @defproc[(list->vector [lst list?]) vector?]{ Returns a mutable vector with the same length and elements as -@scheme[lst].} +@racket[lst].} @defproc[(vector->immutable-vector [vec vector?]) (and/c vector? immutable?)]{ -Returns an immutable vector with the same length and elements as @scheme[vec]. -If @scheme[vec] is itself immutable, then it is returned as the result.} +Returns an immutable vector with the same length and elements as @racket[vec]. +If @racket[vec] is itself immutable, then it is returned as the result.} @defproc[(vector-fill! [vec (and/c vector? (not/c immutable?))] [v any/c]) void?]{ -Changes all slots of @scheme[vec] to contain @scheme[v].} +Changes all slots of @racket[vec] to contain @racket[v].} @defproc[(vector-copy! [dest (and/c vector? (not/c immutable?))] @@ -103,14 +103,14 @@ Changes all slots of @scheme[vec] to contain @scheme[v].} [src-end exact-nonnegative-integer? (vector-length src)]) void?]{ - Changes the elements of @scheme[dest] starting at position - @scheme[dest-start] to match the elements in @scheme[src] from - @scheme[src-start] (inclusive) to @scheme[src-end] (exclusive). The - vectors @scheme[dest] and @scheme[src] can be the same vector, and in + Changes the elements of @racket[dest] starting at position + @racket[dest-start] to match the elements in @racket[src] from + @racket[src-start] (inclusive) to @racket[src-end] (exclusive). The + vectors @racket[dest] and @racket[src] can be the same vector, and in that case the destination region can overlap with the source region; the destination elements after the copy match the source elements - from before the copy. If any of @scheme[dest-start], - @scheme[src-start], or @scheme[src-end] are out of range (taking into + from before the copy. If any of @racket[dest-start], + @racket[src-start], or @racket[src-end] are out of range (taking into account the sizes of the vectors and the source and destination regions), the @exnraise[exn:fail:contract]. @@ -125,21 +125,21 @@ Changes all slots of @scheme[vec] to contain @scheme[v].} [end-pos exact-nonnegative-integer? (vector-length vec)]) any]{ -Returns @math{@scheme[end-pos] - @scheme[start-pos]} values, which are -the elements of @scheme[vec] from @scheme[start-pos] (inclusive) to -@scheme[end-pos] (exclusive). If @scheme[start-pos] or -@scheme[end-pos] are greater than @scheme[(vector-length vec)], or if -@scheme[end-pos] is less than @scheme[start-pos], the +Returns @math{@racket[end-pos] - @racket[start-pos]} values, which are +the elements of @racket[vec] from @racket[start-pos] (inclusive) to +@racket[end-pos] (exclusive). If @racket[start-pos] or +@racket[end-pos] are greater than @racket[(vector-length vec)], or if +@racket[end-pos] is less than @racket[start-pos], the @exnraise[exn:fail:contract].} @defproc[(build-vector [n exact-nonnegative-integer?] [proc (exact-nonnegative-integer? . -> . any/c)]) vector?]{ -Creates a vector of @scheme[n] elements by applying @scheme[proc] to -the integers from @scheme[0] to @scheme[(sub1 n)] in order. If -@scheme[_vec] is the resulting vector, then @scheme[(vector-ref _vec -_i)] is the value produced by @scheme[(proc _i)]. +Creates a vector of @racket[n] elements by applying @racket[proc] to +the integers from @racket[0] to @racket[(sub1 n)] in order. If +@racket[_vec] is the resulting vector, then @racket[(vector-ref _vec +_i)] is the value produced by @racket[(proc _i)]. @examples[ (build-vector 5 add1) @@ -156,11 +156,11 @@ _i)] is the value produced by @scheme[(proc _i)]. @defproc[(vector-map [proc procedure?] [vec vector?] ...+) vector?]{ -Applies @scheme[proc] to the elements of the @scheme[vec]s from the - first elements to the last. The @scheme[proc] argument must accept - the same number of arguments as the number of supplied @scheme[vec]s, - and all @scheme[vec]s must have the same number of elements. The - result is a fresh vector containing each result of @scheme[proc] in +Applies @racket[proc] to the elements of the @racket[vec]s from the + first elements to the last. The @racket[proc] argument must accept + the same number of arguments as the number of supplied @racket[vec]s, + and all @racket[vec]s must have the same number of elements. The + result is a fresh vector containing each result of @racket[proc] in order. @mz-examples[#:eval vec-eval @@ -170,13 +170,13 @@ Applies @scheme[proc] to the elements of the @scheme[vec]s from the @defproc[(vector-map! [proc procedure?] [vec vector?] ...+) vector?]{ -Applies @scheme[proc] to the elements of the @scheme[vec]s from the - first elements to the last. The @scheme[proc] argument must accept - the same number of arguments as the number of supplied @scheme[vec]s, - and all @scheme[vec]s must have the same number of elements. The - each result of @scheme[proc] is inserted into the first @scheme[vec] - at the index that the arguments to @scheme[proc] was taken from. The - result is the first @scheme[vec]. +Applies @racket[proc] to the elements of the @racket[vec]s from the + first elements to the last. The @racket[proc] argument must accept + the same number of arguments as the number of supplied @racket[vec]s, + and all @racket[vec]s must have the same number of elements. The + each result of @racket[proc] is inserted into the first @racket[vec] + at the index that the arguments to @racket[proc] was taken from. The + result is the first @racket[vec]. @mz-examples[#:eval vec-eval (define v #(1 2 3 4)) @@ -195,36 +195,36 @@ of the elements of the given vectors in order. @defproc[(vector-take [vec vector?] [pos exact-nonnegative-integer?]) vector?]{ -Returns a fresh vector whose elements are the first @scheme[pos] elements of -@scheme[vec]. If @scheme[vec] has fewer than -@scheme[pos] elements, then the @exnraise[exn:fail:contract]. +Returns a fresh vector whose elements are the first @racket[pos] elements of +@racket[vec]. If @racket[vec] has fewer than +@racket[pos] elements, then the @exnraise[exn:fail:contract]. @mz-examples[#:eval vec-eval (vector-take #(1 2 3 4) 2) ]} @defproc[(vector-take-right [vec vector?] [pos exact-nonnegative-integer?]) vector?]{ -Returns a fresh vector whose elements are the last @scheme[pos] elements of -@scheme[vec]. If @scheme[vec] has fewer than -@scheme[pos] elements, then the @exnraise[exn:fail:contract]. +Returns a fresh vector whose elements are the last @racket[pos] elements of +@racket[vec]. If @racket[vec] has fewer than +@racket[pos] elements, then the @exnraise[exn:fail:contract]. @mz-examples[#:eval vec-eval (vector-take-right #(1 2 3 4) 2) ]} @defproc[(vector-drop [vec vector?] [pos exact-nonnegative-integer?]) vector?]{ -Returns a fresh vector whose elements are the elements of @scheme[vec] - after the first @scheme[pos] elements. If @scheme[vec] has fewer - than @scheme[pos] elements, then the @exnraise[exn:fail:contract]. +Returns a fresh vector whose elements are the elements of @racket[vec] + after the first @racket[pos] elements. If @racket[vec] has fewer + than @racket[pos] elements, then the @exnraise[exn:fail:contract]. @mz-examples[#:eval vec-eval (vector-drop #(1 2 3 4) 2) ]} @defproc[(vector-drop-right [vec vector?] [pos exact-nonnegative-integer?]) vector?]{ -Returns a fresh vector whose elements are the elements of @scheme[vec] - before the first @scheme[pos] elements. If @scheme[vec] has fewer - than @scheme[pos] elements, then the @exnraise[exn:fail:contract]. +Returns a fresh vector whose elements are the elements of @racket[vec] + before the first @racket[pos] elements. If @racket[vec] has fewer + than @racket[pos] elements, then the @exnraise[exn:fail:contract]. @mz-examples[#:eval vec-eval (vector-drop-right #(1 2 3 4) 2) @@ -234,7 +234,7 @@ Returns a fresh vector whose elements are the elements of @scheme[vec] (values vector? vector?)]{ Returns the same result as -@schemeblock[(values (vector-take vec pos) (vector-drop vec pos))] +@racketblock[(values (vector-take vec pos) (vector-drop vec pos))] except that it can be faster. @@ -246,7 +246,7 @@ except that it can be faster. (values vector? vector?)]{ Returns the same result as -@schemeblock[(values (vector-take-right vec pos) (vector-drop-right vec pos))] +@racketblock[(values (vector-take-right vec pos) (vector-drop-right vec pos))] except that it can be faster. @@ -257,9 +257,9 @@ except that it can be faster. @defproc[(vector-copy [vec vector?] [start exact-nonnegative-integer? 0] [end exact-nonnegative-integer? (vector-length v)]) vector?]{ -Creates a fresh vector of size @scheme[(- end start)], with all of the -elements of @scheme[vec] from @scheme[start] (inclusive) to -@scheme[end] (exclusive). +Creates a fresh vector of size @racket[(- end start)], with all of the +elements of @racket[vec] from @racket[start] (inclusive) to +@racket[end] (exclusive). @mz-examples[#:eval vec-eval (vector-copy #(1 2 3 4)) @@ -269,8 +269,8 @@ elements of @scheme[vec] from @scheme[start] (inclusive) to } @defproc[(vector-filter [pred procedure?] [vec vector?]) vector?]{ -Returns a fresh vector with the elements of @scheme[vec] for which - @scheme[pred] produces a true value. The @scheme[pred] procedure is +Returns a fresh vector with the elements of @racket[vec] for which + @racket[pred] produces a true value. The @racket[pred] procedure is applied to each element from first to last. @mz-examples[#:eval vec-eval @@ -279,9 +279,9 @@ Returns a fresh vector with the elements of @scheme[vec] for which @defproc[(vector-filter-not [pred procedure?] [vec vector?]) vector?]{ -Like @scheme[vector-filter], but the meaning of the @scheme[pred] predicate -is reversed: the result is a vector of all items for which @scheme[pred] -returns @scheme[#f]. +Like @racket[vector-filter], but the meaning of the @racket[pred] predicate +is reversed: the result is a vector of all items for which @racket[pred] +returns @racket[#f]. @mz-examples[#:eval vec-eval (vector-filter-not even? #(1 2 3 4 5 6)) @@ -291,8 +291,8 @@ returns @scheme[#f]. @defproc[(vector-count [proc procedure?] [vec vector?] ...+) exact-nonnegative-integer?]{ -Returns the number of elements of the @scheme[vec ...] (taken in -parallel) on which @scheme[proc] does not evaluate to @scheme[#f]. +Returns the number of elements of the @racket[vec ...] (taken in +parallel) on which @racket[proc] does not evaluate to @racket[#f]. @mz-examples[#:eval vec-eval (vector-count even? #(1 2 3 4 5)) @@ -302,8 +302,8 @@ parallel) on which @scheme[proc] does not evaluate to @scheme[#f]. @defproc[(vector-argmin [proc (-> any/c real?)] [vec vector?]) any/c]{ -This returns the first element in the non-empty vector @scheme[vec] that minimizes -the result of @scheme[proc]. +This returns the first element in the non-empty vector @racket[vec] that minimizes +the result of @racket[proc]. @mz-examples[#:eval vec-eval (vector-argmin car #((3 pears) (1 banana) (2 apples))) @@ -313,8 +313,8 @@ the result of @scheme[proc]. @defproc[(vector-argmax [proc (-> any/c real?)] [vec vector?]) any/c]{ -This returns the first element in the non-empty vector @scheme[vec] that maximizes -the result of @scheme[proc]. +This returns the first element in the non-empty vector @racket[vec] that maximizes +the result of @racket[proc]. @mz-examples[#:eval vec-eval (vector-argmax car #((3 pears) (1 banana) (2 apples))) @@ -328,9 +328,9 @@ the result of @scheme[proc]. @defproc[(vector-member [v any/c] [lst vector?]) (or/c natural-number/c #f)]{ -Locates the first element of @scheme[vec] that is @scheme[equal?] to - @scheme[v]. If such an element exists, the index of that element in - @scheme[vec] is returned. Otherwise, the result is @scheme[#f]. +Locates the first element of @racket[vec] that is @racket[equal?] to + @racket[v]. If such an element exists, the index of that element in + @racket[vec] is returned. Otherwise, the result is @racket[#f]. @mz-examples[ (vector-member 2 (vector 1 2 3 4)) @@ -341,7 +341,7 @@ Locates the first element of @scheme[vec] that is @scheme[equal?] to @defproc[(vector-memv [v any/c] [vec vector?]) (or/c natural-number/c #f)]{ -Like @scheme[member], but finds an element using @scheme[eqv?]. +Like @racket[member], but finds an element using @racket[eqv?]. @mz-examples[ (vector-memv 2 (vector 1 2 3 4)) (vector-memv 9 (vector 1 2 3 4)) @@ -351,7 +351,7 @@ Like @scheme[member], but finds an element using @scheme[eqv?]. @defproc[(vector-memq [v any/c] [vec vector?]) (or/c natural-number/c #f)]{ -Like @scheme[member], but finds an element using @scheme[eq?]. +Like @racket[member], but finds an element using @racket[eq?]. @mz-examples[ (vector-memq 2 (vector 1 2 3 4))