r7rs-small-texinfo

Unnamed repository; edit this file 'description' to name the repository.
git clone https://kaka.farm/~git/r7rs-small-texinfo
Log | Files | Refs

commit 9d59af7ab8d9eca1b9c64c4cf3d93a04dff8c7ba
parent ae31e3a3c1c4d5dc46a6a6254aebae9435e7cea5
Author: Wolfgang Corcoran-Mathe <wcm@sigwinch.xyz>
Date:   Sun,  4 Feb 2024 20:59:19 -0500

Vectors: Reflow & tidy.

Diffstat:
Mdoc/r7rs-small/procedures/vectors.texinfo | 127++++++++++++++++++++++++++++++++++++++-----------------------------------------
1 file changed, 61 insertions(+), 66 deletions(-)

diff --git a/doc/r7rs-small/procedures/vectors.texinfo b/doc/r7rs-small/procedures/vectors.texinfo @@ -1,32 +1,34 @@ @node Vectors @section Vectors -Vectors are heterogeneous structures whose elements are indexed -by integers. A vector typically occupies less space than a list -of the same length, and the average time needed to access a randomly -chosen element is typically less for the vector than for the list. - -The @dfn{length} of a vector is the number of elements that it -contains. This number is a non-negative integer that is fixed when the -vector is created. The @dfn{valid indexes} of a -vector are the exact non-negative integers less than the length of the -vector. The first element in a vector is indexed by zero, and the last -element is indexed by one less than the length of the vector. +Vectors are heterogeneous structures whose elements are indexed by +integers. A vector typically occupies less space than a list of the +same length, and the average time needed to access a randomly chosen +element is typically less for the vector than for the list. + +The @dfn{length} of a vector is the number of elements that it contains. +This number is a non-negative integer that is fixed when the vector is +created. The @dfn{valid indexes} of a vector are the exact non-negative +integers less than the length of the vector. The first element in a +vector is indexed by zero, and the last element is indexed by one less +than the length of the vector. Vectors are written using the notation @code{#(}@var{obj} @dots{}@code{)}. For example, a vector of length 3 containing the number zero in element -0, the list @code{(2 2 2 2)} in element 1, and the string @code{"Anna"} in -element 2 can be written as follows: +0, the list @code{(2 2 2 2)} in element 1, and the string @code{"Anna"} +in element 2 can be written as follows: @lisp #(0 (2 2 2 2) "Anna") @end lisp -Vector constants are self-evaluating, so they do not need to be quoted in programs. +Vector constants are self-evaluating, so they do not need to be quoted +in programs. @deffn procedure vector? obj -Returns @code{#t} if @var{obj} is a vector; otherwise returns @code{#f}. +Returns @code{#t} if @var{obj} is a vector; otherwise returns +@code{#f}. @end deffn @@ -41,11 +43,11 @@ Otherwise the initial contents of each element is unspecified. @deffn procedure vector obj@dots{} -Returns a newly allocated vector whose elements contain the given arguments. It is -analogous to @code{list}. +Returns a newly allocated vector whose elements contain the given +arguments. It is analogous to @code{list}. @lisp -(vector 'a 'b 'c) @result{} #(a b c) +(vector 'a 'b 'c) @result{} #(a b c) @end lisp @end deffn @@ -59,17 +61,17 @@ Returns the number of elements in It is an error if @var{k} is not a valid index of @var{vector}. -The @code{vector-ref} procedure returns the contents of element @var{k} of -@var{vector}. +The @code{vector-ref} procedure returns the contents of element @var{k} +of @var{vector}. @lisp (vector-ref '#(1 1 2 3 5 8 13 21) 5) -@result{} 8 + @result{} 8 (vector-ref '#(1 1 2 3 5 8 13 21) (exact (round (* 2 (acos -1))))) -@result{} 13 + @result{} 13 @end lisp @end deffn @@ -77,16 +79,16 @@ The @code{vector-ref} procedure returns the contents of element @var{k} of It is an error if @var{k} is not a valid index of @var{vector}. -The @code{vector-set!} procedure stores @var{obj} in element @var{k} of @var{vector}. +The @code{vector-set!} procedure stores @var{obj} in element @var{k} of +@var{vector}. @lisp (let ((vec (vector 0 '(2 2 2 2) "Anna"))) (vector-set! vec 1 '("Sue" "Sue")) vec) -@result{} #(0 ("Sue" "Sue") "Anna") + @result{} #(0 ("Sue" "Sue") "Anna") -(vector-set! '#(0 1 2) 1 "doe") -@result{} error ; constant vector +(vector-set! '#(0 1 2) 1 "doe") @result{} @r{error} ; constant vector @end lisp @end deffn @@ -96,20 +98,17 @@ The @code{vector-set!} procedure stores @var{obj} in element @var{k} of @var{vec @deffnx procedure vector->list vector start end @deffnx procedure list->vector list -The @code{vector->list} procedure returns a newly allocated list of the objects contained -in the elements of @var{vector} between @var{start} and @var{end}. -The @code{list->vector} procedure returns a newly +The @code{vector->list} procedure returns a newly allocated list of the +objects contained in the elements of @var{vector} between @var{start} +and @var{end}. The @code{list->vector} procedure returns a newly created vector initialized to the elements of the list @var{list}. In both procedures, order is preserved. @lisp -(vector->list '#(dah dah didah)) -@result{} (dah dah didah) -(vector->list '#(dah dah didah) 1 2) -@result{} (dah) -(list->vector '(dididit dah)) -@result{} #(dididit dah) +(vector->list '#(dah dah didah)) @result{} (dah dah didah) +(vector->list '#(dah dah didah) 1 2) @result{} (dah) +(list->vector '(dididit dah)) @result{} #(dididit dah) @end lisp @end deffn @@ -124,19 +123,17 @@ In both procedures, order is preserved. It is an error if any element of @var{vector} between @var{start} and @var{end} is not a character. -The @code{vector->string} procedure returns a newly allocated string of the objects contained -in the elements of @var{vector} -between @var{start} and @var{end}. -The @code{string->vector} procedure returns a newly -created vector initialized to the elements of the string @var{string} -between @var{start} and @var{end}. +The @code{vector->string} procedure returns a newly allocated string of +the objects contained in the elements of @var{vector} between +@var{start} and @var{end}. The @code{string->vector} procedure returns +a newly created vector initialized to the elements of the string +@var{string} between @var{start} and @var{end}. In both procedures, order is preserved. @lisp -(string->vector "ABC") @result{} #(#\A #\B #\C) -(vector->string - #(#\1 #\2 #\3) @result{} "123" +(string->vector "ABC") @result{} #(#\A #\B #\C) +(vector->string #(#\1 #\2 #\3) @result{} "123" @end lisp @end deffn @@ -145,10 +142,10 @@ In both procedures, order is preserved. @deffnx procedure vector-copy vector start @deffnx procedure vector-copy vector start end -Returns a newly allocated copy of the elements of the given @var{vector} -between @var{start} and @var{end}. -The elements of the new vector are the same (in the sense of -@code{eqv?}) as the elements of the old. +Returns a newly allocated copy of the elements of the given +@var{vector} between @var{start} and @var{end}. The elements of the new +vector are the same (in the sense of @code{eqv?}) as the elements of +the old. @lisp (define a #(1 8 2 8)) ; a may be immutable @@ -164,17 +161,18 @@ c @result{} #(8 2) @deffnx procedure vector-copy! to at from start @deffnx procedure vector-copy! to at from start end -It is an error if @var{at} is less than zero or greater than the length of @var{to}. -It is also an error if @code{(- (vector-length }@var{to}@code{) }@var{at}@code{)} +It is an error if @var{at} is less than zero or greater than the +length of @var{to}. It is also an error if +@code{(- (vector-length }@var{to}@code{) }@var{at}@code{)} is less than @code{(- }@var{end} @var{start}@code{)}. -Copies the elements of vector @var{from} between @var{start} and @var{end} -to vector @var{to}, starting at @var{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. +Copies the elements of vector @var{from} between @var{start} and +@var{end} to vector @var{to}, starting at @var{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. @lisp (define a (vector 1 2 3 4 5)) @@ -187,12 +185,11 @@ b @result{} #(10 1 2 40 50) @deffn procedure vector-append vector@dots{} -Returns a newly allocated vector whose elements are the concatenation of the elements -of the given @var{vector}s. +Returns a newly allocated vector whose elements are the concatenation +of the elements of the given @var{vector}s. @lisp -(vector-append #(a b c) #(d e f)) -@result{} #(a b c d e f) +(vector-append #(a b c) #(d e f)) @result{} #(a b c d e f) @end lisp @end deffn @@ -201,15 +198,13 @@ of the given @var{vector}s. @deffnx procedure vector-fill! vector fill start @deffnx procedure vector-fill! vector fill start end -The @code{vector-fill!} procedure stores @var{fill} -in the elements of @var{vector} -between @var{start} and @var{end}. +The @code{vector-fill!} procedure stores @var{fill} in the elements of +@var{vector} between @var{start} and @var{end}. @lisp (define a (vector 1 2 3 4 5)) (vector-fill! a 'smash 2 4) -a -@result{} #(1 2 smash smash 5) +a @result{} #(1 2 smash smash 5) @end lisp @end deffn