octave-maintainers
[Top][All Lists]
Advanced

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

'length' extension for multiple input arguments?


From: John W. Eaton
Subject: 'length' extension for multiple input arguments?
Date: Wed, 4 Feb 2009 16:27:08 -0500

On  4-Feb-2009, Søren Hauberg wrote:

| If I have a cell array, and I want to know the length of all elements of
| this array, it seems I, essentially, have to do something like
| 
|   for k = 1:length (cell_array)
|     lengths (k) = length (cell_array {k});
|   endfor
| 
| Would an extension to the 'length' function be acceptable that allowed
| for multiple input arguments? This would simply implement the above loop
| and return a vector of integers instead of just an integer. So,
| 
|   length ("hello", 7)
| 
| would return [5, 1]. Such an extension would allow me to write
| 
|   lengths = length (cell_array {:});
| 
| which I think is quite easy to read. Anyway, would such a change be
| acceptable?

Probably you should just use cellfun.

jwe



reply via email to

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