Am Sa., 24. Okt. 2026 um 11:22 Uhr schrieb Michael Scheer <[email protected]>:
>
> Hi guys,
>
> how can I access an array (well I think in Scheme that's no real arrays):
>
>  > #(define myArr '#(10 20 30))

Others already wrote about about quoting while refering to myArr.
In your definition quoting is unneeded as well.
#(define myArr #(10 20 30))
Will do already.

tl;dr
myArr will return #t for (vector? myArr) _and_ (array? myArr), because
a vector like myArr is an array of rank 1, i.e. a special case.
As soon as you want do deal with arrays of higher rank `vector-ref` will error:

#(define myArr #2((1 2 3) (4 5 6)))
%% errors:
%#(pretty-print (vector-ref myArr 0))
%% but:
#(pretty-print (array-ref myArr 0 2))
%% -> 3

Not sure, if you ever want/need such arrays. Though, I think its
cleaner (for yourself) to think of #(10 20 30) as a vector and not a
special array, imho.

Cheers,
Harm

Reply via email to