help-octave
[Top][All Lists]
Advanced

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

list length


From: John W. Eaton
Subject: list length
Date: Fri, 31 Oct 2003 09:53:14 -0600

On 31-Oct-2003, Teemu Ikonen <address@hidden> wrote:

| If I recall, lists are now deprecated in favour of cell arrays, but still, I
| ran into following inconsistency with the CVS version of Octave:
| 
| octave:1> length(list())
| ans = 1
| octave:2> length(list(1))
| ans = 1
| octave:3>
| 
| i.e. the null list has length 1 instead of 0. Of course, there is the odd
| chance that this is so on purpose.

No, this is a bug.  I've checked in the following change.

| Should I remove all the dependencies on lists on my code if I want to use
| the latest Octave, or are they guaranteed to work at least for a while?

They will work for a while, but uses of the list function may start
giving warnings.

| Is there any chance of a new 2.1 -series release soon

There is always a chance.  But seriously, there should be one soon.
But for now I would only recommend it if you want to check out N-d
arrays.  For everything else, I'd recommend 2.1.50.

jwe


src/ChangeLog:

2003-10-31  John W. Eaton  <address@hidden>

        * ov.cc (octave_value::length): If any dim is zero, return 0.

 
Index: ov.cc
===================================================================
RCS file: /usr/local/cvsroot/octave/src/ov.cc,v
retrieving revision 1.94
diff -u -r1.94 ov.cc
--- ov.cc       31 Oct 2003 15:11:45 -0000      1.94
+++ ov.cc       31 Oct 2003 15:49:55 -0000
@@ -839,12 +839,18 @@
   int retval = 0;
 
   dim_vector dv = dims ();
-      
+
   for (int i = 0; i < dv.length (); i++)
     {
       if (dv(i) < 0)
        {
          retval = -1;
+         break;
+       }
+
+      if (dv(i) == 0)
+       {
+         retval = 0;
          break;
        }
 



-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.octave.org
How to fund new projects:  http://www.octave.org/funding.html
Subscription information:  http://www.octave.org/archive.html
-------------------------------------------------------------



reply via email to

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