[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: cell(idx) = [] (was: Re: Re-implementation of inline functions)
From: |
David Bateman |
Subject: |
Re: cell(idx) = [] (was: Re: Re-implementation of inline functions) |
Date: |
Wed, 4 Aug 2004 21:01:32 +0200 |
User-agent: |
Mutt/1.4.1i |
Here is how matlab R12 does it
>> x= cell(1,3); x{1} = 1; x{2} = 2; x{3} = 3, x{1} = [], x(1) = []
x =
[1] [2] [3]
x =
[] [2] [3]
x =
[2] [3]
The difference is in the use of {} or (). Note that you can't do x(1) = 1
in matlab R12 (can you in other versions)
>> x(1) = 1
??? Conversion to cell from double is not possible.
so the () subsref is only for deletion of elements of the cell array...
I don't see any reason to forbid () indexing, just treat an empty array
to () as delete and to {} as include an empty array in the cell array.
Cheers
David
According to John W. Eaton <address@hidden> (on 08/04/04):
> On 4-Aug-2004, David Bateman <address@hidden> wrote:
>
> | > | * finish implementation of cell arrays and struct arrays:
> | > | -- cell(idx) = [] to delete elements
> | > | -- a(1).x = 1; a(2).x = 2; a.x => c.s. list, [a.x] => num array
> | > | -- allow [x{:}] = f (...) to work
> | > | -- and other little details like this...
> | >
> | > I've done some work on some of these problems but have not had time to
> | > finish them. The third item is a bit tricky and may require some
> | > changes to the interface of the octave_value::subsasgn method, so this
> | > is a priority for me if we are going to try to minimize internal
> | > interface changes for the 3.x series.
>
> | The first one seems pretty easy to me as the change is isolated to
> | the '(' case of subsref for cell arrays, and examples of how to
> | treat this case already exist for NDArrays.
>
> I think we need a special type (or some other way) to represent [] so
> that it can be distinguished from "zeros (0, 0)".
>
> jwe
--
David Bateman address@hidden
Motorola CRM +33 1 69 35 48 04 (Ph)
Parc Les Algorithmes, Commune de St Aubin +33 1 69 35 77 01 (Fax)
91193 Gif-Sur-Yvette FRANCE
The information contained in this communication has been classified as:
[x] General Business Information
[ ] Motorola Internal Use Only
[ ] Motorola Confidential Proprietary