6.8 Conversion
syntax
(Listof* A)
syntax
(Vectorof* A)
procedure
(list->array lst) → (Array A)
lst : (Listof A) (list->array ds lst) → (Array A) ds : In-Indexes lst : (Listof A)
procedure
(array->list arr) → (Listof A)
arr : (Array A)
The two-argument variant of list->array assumes the elements in lst are in row-major order.
For array->list, if arr has no axes or more than one axis, it is (conceptually) flattened before being converted to a list.
Examples: | |||||||||||||||||||||
|
The arrays returned by list->array are always strict.
procedure
(vector->array vec) → (Mutable-Array A)
vec : (Vectorof A) (vector->array ds vec) → (Mutable-Array A) ds : In-Indexes vec : (Vectorof A)
procedure
(array->vector arr) → (Vectorof A)
arr : (Array A)
Examples: | ||||||||||||||||||
|
Examples: | ||||||||||||
|
There is no well-typed Typed Racket function that behaves like list*->array but does not require pred?. Without an element predicate, there is no way to prove to the type checker that list*->array’s implementation correctly distinguishes elements from rows.
The arrays returned by list*->array are always strict.
procedure
(array->list* arr) → (Listof* A)
arr : (Array A)
procedure
(vector*->array vecs pred?) → (Mutable-Array A)
vecs : (Vectorof* A) pred? : ((Vectorof* A) -> Any : A)
Examples: | ||||||
|
procedure
(array->vector* arr) → (Vectorof* A)
arr : (Array A)
procedure
(array-list->array arrs [axis]) → (Array A)
arrs : (Listof (Array A)) axis : Integer = 0
Examples: | |||||||||||||||
|
For a similar function that does not increase the dimension of the broadcast arrays, see array-append*.
procedure
(array->array-list arr [axis]) → (Listof (Array A))
arr : (Array A) axis : Integer = 0
Examples: | ||||||||||||
|
6.8.1 Printing
parameter
(array-custom-printer) →
(All (A) ((Array A) Symbol Output-Port (U Boolean 0 1) -> Any)) (array-custom-printer print-array) → void?
print-array :
(All (A) ((Array A) Symbol Output-Port (U Boolean 0 1) -> Any))
procedure
(print-array arr name port mode) → Any
arr : (Array A) name : Symbol port : Output-Port mode : (U Boolean 0 1)
> ((array-custom-printer) (array #[0 1 2 3]) 'my-cool-array (current-output-port) #t) (my-cool-array #[0 1 2 3])