Next: , Previous: , Up: Arrays   [Contents][Index]

#### 5.4.1 Conventional Arrays

The following syntax and procedures are SCM extensions to feature `array` in Arrays in SLIB.

Arrays read and write as a `#` followed by the rank (number of dimensions) followed by the character #\a or #\A and what appear as lists (of lists) of elements. The lists must be nested to the depth of the rank. For each depth, all lists must be the same length.

```(make-array '#(ho) 4 3) ⇒
#2A((ho ho ho) (ho ho ho) (ho ho ho) (ho ho ho))
```

Unshared, conventional (not uniform) 0-based arrays of rank 1 are equivalent to (and can’t be distinguished from) scheme vectors.

```(make-array '#(ho) 3) ⇒ #(ho ho ho)
```
Function: transpose-array array dim0 dim1 …

Returns an array sharing contents with array, but with dimensions arranged in a different order. There must be one dim argument for each dimension of array. dim0, dim1, … should be integers between 0 and the rank of the array to be returned. Each integer in that range must appear at least once in the argument list.

The values of dim0, dim1, … correspond to dimensions in the array to be returned, their positions in the argument list to dimensions of array. Several dims may have the same value, in which case the returned array will have smaller rank than array.

examples:

```(transpose-array '#2A((a b) (c d)) 1 0) ⇒ #2A((a c) (b d))
(transpose-array '#2A((a b) (c d)) 0 0) ⇒ #1A(a d)
(transpose-array '#3A(((a b c) (d e f)) ((1 2 3) (4 5 6))) 1 1 0) ⇒
#2A((a 4) (b 5) (c 6))
```
Function: enclose-array array dim0 dim1 …

dim0, dim1 … should be nonnegative integers less than the rank of array. enclose-array returns an array resembling an array of shared arrays. The dimensions of each shared array are the same as the dimth dimensions of the original array, the dimensions of the outer array are the same as those of the original array that did not match a dim.

An enclosed array is not a general Scheme array. Its elements may not be set using `array-set!`. Two references to the same element of an enclosed array will be `equal?` but will not in general be `eq?`. The value returned by array-prototype when given an enclosed array is unspecified.

examples:

```(enclose-array '#3A(((a b c) (d e f)) ((1 2 3) (4 5 6))) 1) ⇒
```
```#<enclosed-array (#1A(a d) #1A(b e) #1A(c f)) (#1A(1 4) #1A(2 5) #1A(3 6))>
```
```
```
```(enclose-array '#3A(((a b c) (d e f)) ((1 2 3) (4 5 6))) 1 0) ⇒
```
```#<enclosed-array #2A((a 1) (d 4)) #2A((b 2) (e 5)) #2A((c 3) (f 6))>
```
Function: array->list array

Returns a list consisting of all the elements, in order, of array. In the case of a rank-0 array, returns the single element.

Function: array-contents array
Function: array-contents array strict

If array may be unrolled into a one dimensional shared array without changing their order (last subscript changing fastest), then `array-contents` returns that shared array, otherwise it returns `#f`. All arrays made by make-array may be unrolled, some arrays made by make-shared-array may not be.

If the optional argument strict is provided, a shared array will be returned only if its elements are stored internally contiguous in memory.

Next: , Previous: , Up: Arrays   [Contents][Index]