octave-maintainers
[Top][All Lists]
Advanced

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

Attn: Patch Re: iterating cell arrays


From: David Bateman
Subject: Attn: Patch Re: iterating cell arrays
Date: Wed, 23 Jun 2004 11:43:16 +0200
User-agent: Mutt/1.4.1i

Trivial... Consider the patch at the end of this mail. This version
just iterates through all elements of an ND Cell array. It might be
better to also extract sub arrays of the ND Cell array, like what is
done for matrices in a for statement. The version of Matlab R12 I 
have access to does wierd things in this case, so unless someone
want to check the behaviour against a later version of matlab, I
think the version below is pretty much the best that can be done.

Cheer
D.

*** src/pt-loop.cc.orig 2003-10-28 22:07:59.000000000 +0100
--- src/pt-loop.cc      2004-06-23 11:34:32.000000000 +0200
***************
*** 392,397 ****
--- 392,405 ----
              break;
          }
        }
+     else if (rhs.is_cell ())
+       {
+       Cell c_tmp = rhs.cell_value ();
+       dim_vector dv = c_tmp.dims ();
+       int steps = dv.numel ();
+ 
+       DO_LOOP (c_tmp (i));
+       }
      else
        {
        ::error ("invalid type in for loop expression near line %d, column %d",





According to Stefan van der Walt <address@hidden> (on 06/23/04):
> How difficult would it be to implement iterating cell arrays?
> 
> I.e.
> 
> for i = {'one','two','three'}
>   ...
> end
> 
> Regards
> Stéfan

-- 
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



reply via email to

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