octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

indexing arrays and struct arrays with {}?


From: Thorsten Meyer
Subject: indexing arrays and struct arrays with {}?
Date: Sat, 06 Jun 2009 16:19:58 +0200
User-agent: Mozilla-Thunderbird 2.0.0.19 (X11/20090103)

Hi,

While working on the documentation of container types, I found that it is no
longer possible to assign to a subarray of cell array c like this:
  c{:,2} = 1
Instead, the {} operators consistently return a cslist of elements of a cell
array. So, the {} operator now can be seen not to mean
        "index a cell array"
but
        "generate a cs-list of elements (of a cell array)"

At the same time indexing with () means
        "access a subarray"
for arrays, cell arrays and struct arrays.

I think it could be quite useful to generalize the {} operator to arrays and
structs as well, such that
   a = [1, 2, 3; 4, 5, 6];
   a{:,2}
gave the cs-list
   2, 5

And
   b = struct("c", {1,"element2", "element3", 4});
   b{[2,3]}
gave the cs-list
   b(1), b(2)

Unfortunately, I do not have the c++ (or parser ?) skills to implement this.
What do you think of such a change? How much work would it be? And can I maybe
interest one of you octave core programmers in this (:-)?

regards

Thorsten



reply via email to

[Prev in Thread] Current Thread [Next in Thread]