Next: Subarrays, Previous: Data Structures, Up: Data Structures [Contents][Index]
(require 'array)
or (require 'srfi-63)
Returns #t
if the obj is an array, and #f
if not.
Note: Arrays are not disjoint from other Scheme types.
Vectors and possibly strings also satisfy array?
.
A disjoint array predicate can be written:
(define (strict-array? obj) (and (array? obj) (not (string? obj)) (not (vector? obj))))
Returns #t
if obj1 and obj2 have the same rank and dimensions and the
corresponding elements of obj1 and obj2 are equal?
.
equal?
recursively compares the contents of pairs, vectors, strings, and
arrays, applying eqv?
on other objects such as numbers
and symbols. A rule of thumb is that objects are generally equal?
if
they print the same. equal?
may fail to terminate if its arguments are
circular data structures.
(equal? 'a 'a) ⇒ #t (equal? '(a) '(a)) ⇒ #t (equal? '(a (b) c) '(a (b) c)) ⇒ #t (equal? "abc" "abc") ⇒ #t (equal? 2 2) ⇒ #t (equal? (make-vector 5 'a) (make-vector 5 'a)) ⇒ #t (equal? (make-array (A:fixN32b 4) 5 3) (make-array (A:fixN32b 4) 5 3)) ⇒ #t (equal? (make-array '#(foo) 3 3) (make-array '#(foo) 3 3)) ⇒ #t (equal? (lambda (x) x) (lambda (y) y)) ⇒ unspecified
Returns the number of dimensions of obj. If obj is not an array, 0 is returned.
Returns a list of dimensions.
(array-dimensions (make-array '#() 3 5)) ⇒ (3 5)
Creates and returns an array of type prototype with dimensions k1, … and filled with elements from prototype. prototype must be an array, vector, or string. The implementation-dependent type of the returned array will be the same as the type of prototype; except if that would be a vector or string with rank not equal to one, in which case some variety of array will be returned.
If the prototype has no elements, then the initial contents of the returned array are unspecified. Otherwise, the returned array will be filled with the element at the origin of prototype.
create-array
is an alias for make-array
.
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
list must be a rank-nested list consisting of all the elements, in row-major order, of the array to be created.
list->array
returns an array of rank rank and type proto consisting of all the
elements, in row-major order, of list. When rank is 0, list is the lone
array element; not necessarily a list.
(list->array 2 '#() '((1 2) (3 4))) ⇒ #2A((1 2) (3 4)) (list->array 0 '#() 3) ⇒ #0A 3
Returns a rank-nested list consisting of all the elements, in
row-major order, of array. In the case of a rank-0 array, array->list
returns
the single element.
(array->list #2A((ho ho ho) (ho oh oh))) ⇒ ((ho ho ho) (ho oh oh)) (array->list #0A ho) ⇒ ho
vect must be a vector of length equal to the product of exact nonnegative integers dim1, ….
vector->array
returns an array of type proto consisting of all the elements, in
row-major order, of vect. In the case of a rank-0 array, vect has a
single element.
(vector->array #(1 2 3 4) #() 2 2) ⇒ #2A((1 2) (3 4)) (vector->array '#(3) '#()) ⇒ #0A 3
Returns a new vector consisting of all the elements of array in row-major order.
(array->vector #2A ((1 2)( 3 4))) ⇒ #(1 2 3 4) (array->vector #0A ho) ⇒ #(ho)
Returns #t
if its arguments would be acceptable to
array-ref
.
Returns the (k1, …) element of array.
Stores obj in the (k1, …) element of array. The value returned
by array-set!
is unspecified.
These functions return a prototypical uniform-array enclosing the optional argument (which must be of the correct type). If the uniform-array type is supported by the implementation, then it is returned; defaulting to the next larger precision type; resorting finally to vector.
Returns an inexact 128.bit flonum complex uniform-array prototype.
Returns an inexact 64.bit flonum complex uniform-array prototype.
Returns an inexact 32.bit flonum complex uniform-array prototype.
Returns an inexact 16.bit flonum complex uniform-array prototype.
Returns an inexact 128.bit flonum real uniform-array prototype.
Returns an inexact 64.bit flonum real uniform-array prototype.
Returns an inexact 32.bit flonum real uniform-array prototype.
Returns an inexact 16.bit flonum real uniform-array prototype.
Returns an exact 128.bit decimal flonum rational uniform-array prototype.
Returns an exact 64.bit decimal flonum rational uniform-array prototype.
Returns an exact 32.bit decimal flonum rational uniform-array prototype.
Returns an exact binary fixnum uniform-array prototype with at least 64 bits of precision.
Returns an exact binary fixnum uniform-array prototype with at least 32 bits of precision.
Returns an exact binary fixnum uniform-array prototype with at least 16 bits of precision.
Returns an exact binary fixnum uniform-array prototype with at least 8 bits of precision.
Returns an exact non-negative binary fixnum uniform-array prototype with at least 64 bits of precision.
Returns an exact non-negative binary fixnum uniform-array prototype with at least 32 bits of precision.
Returns an exact non-negative binary fixnum uniform-array prototype with at least 16 bits of precision.
Returns an exact non-negative binary fixnum uniform-array prototype with at least 8 bits of precision.
Returns a boolean uniform-array prototype.
Next: Subarrays, Previous: Data Structures, Up: Data Structures [Contents][Index]