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 ae31e3a3c1c4d5dc46a6a6254aebae9435e7cea5
parent a2108138ae0bb1ba17a66a18c4f349d681f84ec8
Author: Wolfgang Corcoran-Mathe <wcm@sigwinch.xyz>
Date:   Sun,  4 Feb 2024 20:55:26 -0500

Vectors: Texify.

Diffstat:
Mdoc/r7rs-small/procedures/vectors.texinfo | 193++++++++++++++++++++++++++++---------------------------------------------------
1 file changed, 68 insertions(+), 125 deletions(-)

diff --git a/doc/r7rs-small/procedures/vectors.texinfo b/doc/r7rs-small/procedures/vectors.texinfo @@ -1,45 +1,48 @@ @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. +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: -The 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 valid indexesof 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 #( - -obj @dots{}). For example, a vector of length 3 containing the number zero in element 0, the -list (2 2 2 2) in element 1, and the string "Anna" in element 2 can be written as follows: +@lisp +#(0 (2 2 2 2) "Anna") +@end lisp -#(0 (2 2 2 2) "Anna") 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 #t if +Returns @code{#t} if @var{obj} is a vector; otherwise returns @code{#f}. -obj is a vector; otherwise returns #f. @end deffn @deffn procedure make-vector k @deffnx procedure make-vector k fill -Returns a newly allocated vector of +Returns a newly allocated vector of @var{k} elements. If a second +argument is given, then each element is initialized to @var{fill}. +Otherwise the initial contents of each element is unspecified. -k elements. If a second argument is given, then each element is initialized to - -fill. Otherwise the initial contents of each element is unspecified. @end deffn -@deffn procedure vector obj @dots{} +@deffn procedure vector obj@dots{} Returns a newly allocated vector whose elements contain the given arguments. It is -analogous to list. +analogous to @code{list}. @lisp (vector 'a 'b 'c) @result{} #(a b c) @@ -49,23 +52,15 @@ analogous to list. @deffn procedure vector-length vector Returns the number of elements in - -vector as an exact integer. +@var{vector} as an exact integer. @end deffn @deffn procedure vector-ref vector k -It is an error if - -k is not a valid index of +It is an error if @var{k} is not a valid index of @var{vector}. -vector. - -The vector-ref procedure returns the contents of element - -k of - -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) @@ -80,19 +75,9 @@ vector. @deffn procedure vector-set! vector k obj -It is an error if - -k is not a valid index of - -vector. - -The vector-set! procedure stores +It is an error if @var{k} is not a valid index of @var{vector}. -obj in element - -k of - -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"))) @@ -103,6 +88,7 @@ vector. (vector-set! '#(0 1 2) 1 "doe") @result{} error ; constant vector @end lisp + @end deffn @deffn procedure vector->list vector @@ -110,17 +96,10 @@ vector. @deffnx procedure vector->list vector start end @deffnx procedure list->vector list -The vector->list procedure returns a newly allocated list of the objects contained in the -elements of - -vector between - -start and - -end. The list->vector procedure returns a newly created vector initialized to the elements -of the list - -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 +created vector initialized to the elements of the list @var{list}. In both procedures, order is preserved. @@ -132,6 +111,7 @@ In both procedures, order is preserved. (list->vector '(dididit dah)) @result{} #(dididit dah) @end lisp + @end deffn @deffn procedure vector->string vector @@ -141,29 +121,15 @@ In both procedures, order is preserved. @deffnx procedure string->vector string start @deffnx procedure string->vector string start end -It is an error if any element of - -vector between - -start and - -end is not a character. - -The vector->string procedure returns a newly allocated string of the objects contained in -the elements of - -vector between +It is an error if any element of @var{vector} between @var{start} +and @var{end} is not a character. -start and - -end. The string->vector procedure returns a newly created vector initialized to the -elements of the string - -string between - -start and - -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. @@ -172,20 +138,17 @@ In both procedures, order is preserved. (vector->string #(#\1 #\2 #\3) @result{} "123" @end lisp + @end deffn @deffn procedure vector-copy vector @deffnx procedure vector-copy vector start @deffnx procedure vector-copy vector start end -Returns a newly allocated copy of the elements of the given - -vector between - -start and - -end. The elements of the new vector are the same (in the sense of 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 @@ -201,34 +164,17 @@ 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 - -at is less than zero or greater than the length of - -to. It is also an error if (- (vector-length - -to) - -at) is less than (- - -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{)} +is less than @code{(- }@var{end} @var{start}@code{)}. -start). - -Copies the elements of vector - -from between - -start and - -end to vector - -to, starting at - -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)) @@ -236,32 +182,28 @@ making sure to copy in the correct direction in such circumstances. (vector-copy! b 1 a 0 2) b @result{} #(10 1 2 40 50) @end lisp + @end deffn @deffn procedure vector-append vector@dots{} Returns a newly allocated vector whose elements are the concatenation of the elements -of the given vectors. +of the given @var{vector}s. @lisp (vector-append #(a b c) #(d e f)) @result{} #(a b c d e f) @end lisp + @end deffn @deffn procedure vector-fill! vector fill @deffnx procedure vector-fill! vector fill start @deffnx procedure vector-fill! vector fill start end -The vector-fill! procedure stores - -fill in the elements of - -vector between - -start and - -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)) @@ -269,4 +211,5 @@ end. a @result{} #(1 2 smash smash 5) @end lisp + @end deffn