6.11 Indexing and Slicing
procedure
(array-ref arr js) → A
arr : (Array A) js : In-Indexes
procedure
(array-set! arr js value) → Void
arr : (Settable-Array A) js : In-Indexes value : A
procedure
(array-indexes-ref arr idxs) → (Array A)
arr : (Array A) idxs : (Array In-Indexes)
Examples: | |||||||||
|
> (build-array (array-shape idxs) (λ: ([js : Indexes]) (array-ref arr (array-ref idxs js)))) - : (Array Positive-Byte)
(array #[1 20])
procedure
(array-indexes-set! arr idxs vals) → Void
arr : (Settable-Array A) idxs : (Array In-Indexes) vals : (Array A)
Examples: | ||||||||||||
|
procedure
(array-slice-ref arr specs) → (Array A)
arr : (Array A) specs : (Listof Slice-Spec)
procedure
(array-slice-set! arr specs vals) → Void
arr : (Settable-Array A) specs : (Listof Slice-Spec) vals : (Array A)
(let ([idxs (array-slice-ref (indexes-array (array-shape arr)) specs)]) (array-indexes-set! arr idxs vals))
Examples: | ||||||||||||||||||||||||||||||
|
syntax
A (Sequenceof Integer) slice specification causes array-slice-ref to pick rows from an axis. An Integer slice specification causes array-slice-ref to remove an axis by replacing it with one of its rows.
See Slicing for an extended example.
syntax
procedure
end : (U #f Integer) = #f (:: start end [step]) → Slice start : (U #f Integer) end : (U #f Integer) step : Integer = 1
procedure
v : Any
procedure
(slice-start s) → (U #f Fixnum)
s : Slice
procedure
s : Slice
procedure
(slice-step s) → Fixnum
s : Slice
array-slice-ref interprets a Slice like an in-range sequence object. When start or end is #f, it is interpreted as an axis-length-dependent endpoint.
This is used internally by array-slice-ref to interpret a Slice object as a sequence of indexes.
syntax
value
procedure
(slice-dots? v) → Boolean
v : Any
syntax
procedure
(::new [dk]) → Slice-New-Axis
dk : Integer = 1
procedure
(slice-new-axis? v) → Boolean
v : Any
procedure
(slice-new-axis-length s) → Index
s : Slice-New-Axis