[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [major] struct array indexing in tip
From: |
Thorsten Meyer |
Subject: |
Re: [major] struct array indexing in tip |
Date: |
Sat, 24 Jan 2009 14:11:12 +0100 |
User-agent: |
Mozilla-Thunderbird 2.0.0.19 (X11/20090103) |
John W. Eaton wrote:
> We need the tests, so I'm hoping someone else will have the time to do
> it. Anyone?
While generating some tests for structure indexing, I came across this behaviour
in octave (revision 83b8c739d626):
octave:165> clear
octave:166> b=struct ("name", {"a", "b", "c"; "d", "e", "f"}, "value", 0);
octave:167> b(1, [1,3]).name
ans = a
ans = c
octave:168> [b(1, [1,3]).name] = deal("aa", "cc");
octave:169> b(1, [1,3]).name
ans = aa
ans = cc
this works as I would have expected. However:
octave:173> [b(1:2, [1,3]).name] = deal("aaa", "ddd", "ccc", "fff");
error: A(I,J,...) = X: dimensions mismatch
Is that intended behaviour?
Now trying to nest struct arrays:
octave:173> b(3,1).value = b;
octave:174> b(3,1).value(1, [1,3]).name
ans = aa
ans = cc
octave:175> [b(3,1).value(1, [1,3]).name] = deal("aaa", "ccc")
error: invalid cs-list length in assignment
error: assignment to structure element failed
error: assignment failed, or no method for `struct = cs-list'
Should that work or have I misunderstood something?
regards
Thorsten