Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

array subscript manipulation

21 views
Skip to first unread message

Jinsong Zhao

unread,
Apr 17, 2014, 12:34:49 AM4/17/14
to
Hi there,

I have an array:

(defvar x (make-array '(5 5) :initial-contents '((1 1 1 1 1)
(2 2 2 2 2)
(3 3 3 3 3)
(4 4 4 4 4)
(5 5 5 5 5))))
Is there a easy way to access or get whole column? For row, I can use
:displaced-to.

Another question, is there a easy way to get x[2, 2:4]?

Thanks in advance.

Best wishes,
Jinsong

Marco Antoniotti

unread,
Apr 17, 2014, 3:13:46 AM4/17/14
to
On Thursday, April 17, 2014 6:34:49 AM UTC+2, Jinsong Zhao wrote:
> Hi there,
> I have an array:
>
> (defvar x (make-array '(5 5) :initial-contents '((1 1 1 1 1)
> (2 2 2 2 2)
> (3 3 3 3 3)
> (4 4 4 4 4)
> (5 5 5 5 5))))
>
> Is there a easy way to access or get whole column? For row, I can use
> :displaced-to.

No. There is no way to access a "column" unless you copy. Arrays are stored in row major form.

> Another question, is there a easy way to get x[2, 2:4]?

Not directly in the standard. There are libraries and bits and pieces of code to do that.

I should have something laying around. Drop me a line in private...

Cheers
--
MA

0 new messages