indexing arrays and struct arrays with {}?

Thorsten Meyer thorsten.meyier at gmx.de
Sat Jun 6 09:19:58 CDT 2009


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



More information about the Octave-maintainers mailing list