GNU Info

Info Node: (slib.info)Arrays

(slib.info)Arrays


Next: Array Mapping Prev: Data Structures Up: Data Structures
Enter node , (file) or (file)node

Arrays
------

  `(require 'array)'

 - Function: array? obj
     Returns `#t' if the OBJ is an array, and `#f' if not.

_Note:_ Arrays are not disjoint from other Scheme types.  Strings and
vectors also satisfy `array?'.  A disjoint array predicate can be
written:

     (define (strict-array? obj)
       (and (array? obj) (not (string? obj)) (not (vector? obj))))

 - Function: array=? array1 array2
     Returns `#t' if ARRAY1 and ARRAY2 have the same rank and shape and
     the corresponding elements of ARRAY1 and ARRAY2 are `equal?'.

          (array=? (make-array 'foo 3 3) (make-array 'foo '(0 2) '(1 2)))
            => #t

 - Function: make-array initial-value bound1 bound2 ...
     Creates and returns an array with dimensions BOUND1, BOUND2, ...
     and filled with INITIAL-VALUE.

When constructing an array, BOUND is either an inclusive range of
indices expressed as a two element list, or an upper bound expressed as
a single integer.  So

     (make-array 'foo 3 3) == (make-array 'foo '(0 2) '(0 2))

 - Function: make-shared-array array mapper bound1 bound2 ...
     `make-shared-array' can be used to create shared subarrays of other
     arrays.  The MAPPER is a function that translates coordinates in
     the new array into coordinates in the old array.  A MAPPER must be
     linear, and its range must stay within the bounds of the old
     array, but it can be otherwise arbitrary.  A simple example:

          (define fred (make-array #f 8 8))
          (define freds-diagonal
            (make-shared-array fred (lambda (i) (list i i)) 8))
          (array-set! freds-diagonal 'foo 3)
          (array-ref fred 3 3)
             => FOO
          (define freds-center
            (make-shared-array fred (lambda (i j) (list (+ 3 i) (+ 3 j)))
                               2 2))
          (array-ref freds-center 0 0)
             => FOO

 - Function: array-rank obj
     Returns the number of dimensions of OBJ.  If OBJ is not an array,
     0 is returned.

 - Function: array-shape array
     Returns a list of inclusive bounds.

          (array-shape (make-array 'foo 3 5))
             => ((0 2) (0 4))

 - Function: array-dimensions array
     `array-dimensions' is similar to `array-shape' but replaces
     elements with a 0 minimum with one greater than the maximum.

          (array-dimensions (make-array 'foo 3 5))
             => (3 5)

 - Function: array-in-bounds? array index1 index2 ...
     Returns `#t' if its arguments would be acceptable to `array-ref'.

 - Function: array-ref array index1 index2 ...
     Returns the (INDEX1, INDEX2, ...) element of ARRAY.

 - Function: array-set! array obj index1 index2 ...
     Stores OBJ in the (INDEX1, INDEX2, ...) element of ARRAY.  The
     value returned by `array-set!' is unspecified.


automatically generated by info2www version 1.2.2.9