Hi all,

Besides optim, lists were also used in a few other packages, namely main/vrml, extra/tk_octave and main/symbolic. I've replaced these lists with cells with the attached patches (r7327 and r7336).

The testing functions test_vmesh and test_vrml_faces run successfully up to the point of calling freewrl, which I do not have installed. test_moving_surf failed with an error on "`data2vrml' undefined ". I did not do any tests on symbolic or tk_octave, because I do not know how to do it.

In main/miscellaneous/inst/read_options.m, I noticed a function call to lgrep(), but no lgrep can be found anywhere.

In summary, lists should be gone by now anywhere in octave-sf.


  Alois



etie...@isr.ist.utl.pt wrote:
   Hi all,

deleting leval.cc should be ok. Iirc, it was created mainly for the optimization functions and has no advantage over feval (funcName, argCell{:}), now that octave has cells.

If anyone has tons of code riddled with lists, it should be easy enough to have list look-alike functions implemented in terms of cells.

   Just my 2c,

   Etienne

Quoting Thomas Weber <twe...@debian.org> (Fri, 21 May 2010 20:18:39 +0200):

On Fri, May 21, 2010 at 01:42:50PM +0200, Michael Creel wrote:
I checked in a modified  Makefile so that leval.cc is not compiled. I
guess that leval.cc could be removed, but maybe we should wait on that
(?).
If you think it's superfluous, delete it now. If someone needs it later,
they can (and will) complain. However, four weeks from now no one will
remember to delete leval.cc, if it's still there.

        Thomas

------------------------------------------------------------------------------

_______________________________________________
Octave-dev mailing list
Octave-dev@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/octave-dev





Index: extra/tk_octave/inst/tk_scale.m
===================================================================
--- extra/tk_octave/inst/tk_scale.m	(revision 7326)
+++ extra/tk_octave/inst/tk_scale.m	(revision 7327)
@@ -1,3 +1,4 @@
+
 ## Copyright (C) 1998, 1999, 2000 Joao Cardoso.
 ## 
 ## This program is free software; you can redistribute it and/or modify it
@@ -52,11 +53,11 @@
 va_arg_cnt = 1;
 
 for i=1:nopt
-    desc = nth (varargin, va_arg_cnt++);
-    val = nth (varargin, va_arg_cnt++);
-    min_val = nth (varargin, va_arg_cnt++);
-    max_val = nth (varargin, va_arg_cnt++);
-    inc_val = nth (varargin, va_arg_cnt++);
+    desc = varargin{va_arg_cnt++};
+    val = varargin{va_arg_cnt++};
+    min_val = varargin{va_arg_cnt++};
+    max_val = varargin{va_arg_cnt++};
+    inc_val = varargin{va_arg_cnt++};
 	
     tk_cmd( sprintf("set val_%d %f", i, val) );
     tk_cmd( sprintf("scale .master.s%d -from %f -to %f \
@@ -69,9 +70,9 @@
 
 tk_cmd( "tkwait window .master" );
 	
-vr_val_cnt = 1;
 for i=1:nopt
-    varargout{vr_val_cnt++} = eval([tk_cmd(sprintf("set val_%d",i)), ";"]);
+    varargout{i} = eval([tk_cmd(sprintf("set val_%d",i)), ";"]);
 endfor
 
 endfunction
+
Index: extra/tk_octave/inst/tk_dialog.m
===================================================================
--- extra/tk_octave/inst/tk_dialog.m	(revision 7326)
+++ extra/tk_octave/inst/tk_dialog.m	(revision 7327)
@@ -64,7 +64,7 @@
 #varargin = list(varargin, all_va_args);
 
 for argnum=1:length(varargin)
-	arg = nth (varargin, argnum);
+	arg = varargin{argnum};
 	if (! ischar(arg))
 		error("The arguments must be strings.\n");
 		return
Index: extra/tk_octave/inst/tk_menu.m
===================================================================
--- extra/tk_octave/inst/tk_menu.m	(revision 7326)
+++ extra/tk_octave/inst/tk_menu.m	(revision 7327)
@@ -36,10 +36,8 @@
 
 nopt = nargin - 1;
 
-va_arg_cnt = 1;
-
 for i = 1:nopt
-	tk_cmd( sprintf ("button .master.b%d -text \"%s\" -command { set menuChoice %d; quit}", i, nth (varargin, va_arg_cnt++), i) );
+	tk_cmd( sprintf ("button .master.b%d -text \"%s\" -command { set menuChoice %d; quit}", i, varargin{i}, i) );
 	tk_cmd( sprintf ("pack .master.b%d -fill x", i) );
 endfor
 
Index: extra/graceplot/inst/alternatives/print.m
===================================================================
--- extra/graceplot/inst/alternatives/print.m	(revision 7326)
+++ extra/graceplot/inst/alternatives/print.m	(revision 7327)
@@ -1,3 +1,4 @@
+
 ## Copyright (C) 2001 Laurent Mazet
 ##
 ## This program is free software; it is distributed in the hope that it
@@ -124,7 +125,7 @@
   va_arg_cnt = 1;
 
   for i=1:nargin
-    arg = nth (varargin, va_arg_cnt++);
+    arg = varargin{va_arg_cnt++}; 
     if ischar(arg)
       if strcmp(arg, "-color")
 	use_color = 1;
@@ -412,3 +413,4 @@
   endif
 
 endfunction
+
Index: main/vrml/inst/vrml_TimeSensor.m
===================================================================
--- main/vrml/inst/vrml_TimeSensor.m	(revision 7326)
+++ main/vrml/inst/vrml_TimeSensor.m	(revision 7327)
@@ -36,27 +36,29 @@
 "loop",          "SFBool"
 );
 
-headpar = list ();
+headpar = {};
 dnode = struct ();
 
 				# Transform varargin into key-value pairs
 i = j = k = 1;			# i:pos in new varargin, j:pos in headpar,
 				# k:pos is old varargin.
 while i <= length (varargin) && \
-      ! (ischar (nth (varargin,i)) && struct_contains (tpl, nth (varargin,i)))
+      ! (ischar (varargin{i}) && isfield (tpl, varargin{i}))
   
   if j <= length (headpar)
 
     if verbose
-      printf ("vrml_TimeSensor : Assume arg %i is '%s'\n",k,nth(headpar,j));
+      printf ("vrml_TimeSensor : Assume arg %i is '%s'\n",k,headpar{j});
     end
 
-    varargin = splice (varargin, i, 0, headpar(j++));
+    ##varargin = splice (varargin, i, 0, headpar(j));
+    varargin = {varargin{1:i-1}, headpar(j), varargin{i:end}};
+    j ++; 
     i += 2;
     k++;
   else
     error ("vrml_TimeSensor : Argument %i should be string, not '%s'",\
-	   k,typeinfo (nth (varargin, i)));
+	   k,typeinfo (varargin{i}));
   end
 end
 
@@ -65,76 +67,55 @@
 
 DEF = 0;
 
-l = list ("TimeSensor {\n");
+l = {"TimeSensor {\n"};
 i = 1;
 while i < length (varargin)
 
-  k = nth (varargin, i++);	# Read key
+  k = varargin{i++};	# Read key
 
   if ! ischar (k)
     error ("vrml_TimeSensor : Arg n. %i should be a string, not a %s.",\
 	   i-1, typeinfo (k));
   end
-  if ! struct_contains (tpl, k) && ! strcmp (k,"DEF")
+  if ! isfield (tpl, k) && ! strcmp (k,"DEF")
     error ("vrml_TimeSensor : Unknown field '%s'. Should be one of :\n%s",\
 	    k, sprintf ("   '%s'\n",fieldnames (tpl)'{:}));
   end
 
-  v = nth (varargin, i++);	# Read value
+  v = varargin{i++};	# Read value
 				# Add DEF
   if strcmp (k,"DEF")
 
     if verbose, printf ("vrml_TimeSensor : Defining node '%s'\n",v); end
 
     if DEF, error ("vrml_TimeSensor : Multiple DEFs found"); end
-    l = splice (l,1,0,list ("DEF ",v," "));
+    ##l = splice (l,1,0,{"DEF ",v," "});
+    varargin = {"DEF ",v," ",l};
     DEF = 1;
 
   else				# Add data field
 
     if verbose
       printf ("vrml_TimeSensor : Adding '%s' of type %s, with arg of type %s\n",\
-	      k,tpl.(k),typeinfo (v));
+	      k,getfield(tpl,k),typeinfo (v));
     end
-    if strcmp (tpl.(k)(2:length(tpl.(k))), "FNode")
+    tmp = getfield(tpl,k);
+    if strcmp (tmp(2:end), "FNode")
 
       if verbose, printf ("vrml_TimeSensor : Trying to learn type of node\n"); end
 
-      if is_list (v)		# v is list of arguments
-
-				# Check whether 1st arg is node type's name.
-	tn = nth (v,1);
-
-	if all (exist (["vrml_",tn]) != [2,3,5])
-	  			# If it isn't type's name, use default type.
-	  if struct_contains (dnode, k)
-	    if verbose
-	      printf ("vrml_TimeSensor : Using default type : %s\n",dnode.(k));
-	    end
-	    v = splice (v, 1, 0,  list (dnode.(k)));
-	  else
-	    error ("vrml_TimeSensor : Can't determine type of node '%s'",k);
-	  end
-	else
-	  if verbose
-	    printf ("vrml_TimeSensor : 1st list element is type : %s\n",tn);
-	  end
-	end
-				# If v is not a list, maybe it has a default
-				# node type type (otherwise, it's be sent
-				# plain.
-      elseif struct_contains (dnode, k)
+      if isfield (dnode, k)
 	if verbose
 	  printf ("vrml_TimeSensor : Using default type : %s\n",dnode.(k));
 	end
-	v = list (dnode.(k), v);
+	v = {getfield(dnode,k), v};
       end
     end
-    l = append (l, k, " ", data2vrml (tpl.(k), v),"\n");
+    l = {l{:}, k, " ", data2vrml(getfield(tpl,k),v),"\n"};
   end
   
 end
-l = append (l, "}\n");
-s = leval ("strcat", l);
+l{end+1} = "}\n";
+s = feval ("strcat", l{:});
 endfunction
 
Index: main/vrml/inst/vrml_newname.m
===================================================================
--- main/vrml/inst/vrml_newname.m	(revision 7326)
+++ main/vrml/inst/vrml_newname.m	(revision 7327)
@@ -14,7 +14,7 @@
 if isempty (root), root = "N"; end
 
 n = sprintf ([root,"%0d"],100000*rand());
-while struct_contains (vrml_namespace, n)
+while isfield (vrml_namespace, n)
   n = sprintf ([root,"%0d"],100000*rand());
 end
 endfunction
Index: main/vrml/inst/vrml_interp.m
===================================================================
--- main/vrml/inst/vrml_interp.m	(revision 7326)
+++ main/vrml/inst/vrml_interp.m	(revision 7327)
@@ -27,15 +27,17 @@
 		       "Position"   , "Position",
 		       "scal"       , "Scalar",
 		       "Scalar"     , "Scalar");
-if struct_contains (nname, typ)
+if isfield (nname, typ)
   typs = nname.(typ);
 elseif ischar(typ)
-  e2 = leval ("sprintf",\
-	      append (list("    '%s'\n"), fieldnames (nname)));
+#  e2 = leval ("sprintf",\
+#	      append (list("    '%s'\n"), fieldnames (nname)));
+  e2 = sprintf("    '%s'\n", fieldnames (nname){:});
   error ("vrml_interp : Unknown type '%s'. Should be in:\n%s",typ,e2);
 else
-  e2 = leval ("sprintf",\
-	      append (list("    '%s;\n"), fieldnames (nname)));
+#  e2 = leval ("sprintf",\
+#	      append (list("    '%s;\n"), fieldnames (nname)));
+  e2 = sprintf("    '%s'\n", fieldnames (nname){:});
   error ("vrml_interp : typ should be a string in:\n%s",typ,e2);
 end
 
Index: main/vrml/inst/vrml_points.m
===================================================================
--- main/vrml/inst/vrml_points.m	(revision 7326)
+++ main/vrml/inst/vrml_points.m	(revision 7327)
@@ -1,3 +1,4 @@
+
 ## Copyright (C) 2002 Etienne Grossmann.  All rights reserved.
 ##
 ## This program is free software; you can redistribute it and/or modify it
@@ -65,7 +66,7 @@
 
 while i <= nargin-1
 
-  tmp = nth (varargin,i++);
+  tmp = varargin{i++};
   if strcmp(tmp,"hide") ,
     hide = 1;
   elseif strcmp(tmp,"balls") ,
@@ -74,20 +75,20 @@
     cubes = 1;
   elseif strcmp(tmp,"rad") ,
 
-    rad = nth (varargin,i++);
+    rad = varargin{i++};
   elseif strcmp(tmp,"nums") ,
     nums = 1;
   elseif strcmp(tmp,"emit") ,
 
-    emit = nth (varargin,i++);
+    emit = varargin{i++};
   elseif strcmp(tmp,"col") ,
 
-    col = nth (varargin,i++);
+    col = varargin{i++};
   elseif strcmp(tmp,"name") ,
 
-    name = nth (varargin,i++);
+    name = varargin{i++};
   elseif strcmp(tmp,"tran") ,
-    tran = nth (varargin,i++);
+    tran = varargin{i++};
   end
 end
 
@@ -218,3 +219,4 @@
 end
 endfunction
 
+
Index: main/vrml/inst/test_vrml_faces.m
===================================================================
--- main/vrml/inst/test_vrml_faces.m	(revision 7326)
+++ main/vrml/inst/test_vrml_faces.m	(revision 7327)
@@ -25,7 +25,7 @@
        2 3 1 2;
        4 4 4 3];
 
-trgl = list ([1 2 4],[2 3 4],[3 1 4],[1 2 3]);
+trgl = {[1 2 4],[2 3 4],[3 1 4],[1 2 3]};
 
 slight = vrml_PointLight ("location", [0,5,0]);
 
Index: main/vrml/inst/vrml_faces.m
===================================================================
--- main/vrml/inst/vrml_faces.m	(revision 7326)
+++ main/vrml/inst/vrml_faces.m	(revision 7327)
@@ -95,7 +95,7 @@
 
   i = 1;
   while nargin>=i	
-    tmp = nth (varargin, i++);
+    tmp = varargin{i++};
     if ! ischar(tmp) ,
       error ("vrml_faces : Non-string option : \n") ;
       ## keyboard
@@ -103,7 +103,7 @@
 
     if index(opt1,[" ",tmp," "]) ,
       
-      tmp2 = nth (varargin, i++) ;
+      tmp2 = varargin{i++} ;
 
       eval([tmp,"=tmp2;"]) ;
 
@@ -131,11 +131,7 @@
 
   ## printf ("creaseAngle = %8.3f\n",creaseAngle);
 
-  ## TODO : s/list/cell/g; Should put this code in sometime soon
-  ## if is_list (f), tmp={}; for i=1:length(f), tmp{i}=nth(f,i);end; f=tmp; end;
-  ## if is_list (f), nfaces = length (f); else nfaces = columns (f); end
-
-  if is_list (f), nfaces = length (f); else nfaces = columns (f); end
+  nfaces = columns (f); 
   if ismatrix(f)
     if rows (f) < 3
       error ("Faces matrix 'f' has %i < 3 rows, so it does not define faces",
@@ -254,7 +250,7 @@
   ## TODO : s/list/cell/g; Should put this code in sometime soon
   ## Code below seems useless
 				# Faces 
-  if is_list (f), nfaces = length (f); else nfaces = columns (f); end
+  if iscell (f), nfaces = length (f); else nfaces = columns (f); end
 
 
   tpl0 = sprintf ("%%%dd, ",floor (log10 (max (1, columns (x))))+1);
@@ -265,15 +261,15 @@
 				# Determine total number of vertices, number
 				# of vertices per face and indexes of
 				# vertices of each face
-  ## TODO : s/list/cell/g; Should put this code in sometime soon
-  ## if iscell (f), ... f{i} 
-  if is_list (f)			
-
+  if iscell (f)			
     npts = 0;
-    for i = 1:length (f), npts += ptsface(i) = 1+length (nth (f,i)); end
+    for i = 1:length (f), 
+       ptsface(i) = 1+length (f{i});
+       npts += ptsface(i);  
+    end
     ii = [0, cumsum(ptsface)]';
     all_indexes = -ones (1,npts);
-    for i = 1:length (f), all_indexes(ii(i)+1:ii(i+1)-1) = nth (f,i) - 1; end
+    for i = 1:length (f), all_indexes(ii(i)+1:ii(i+1)-1) = f{i} - 1; end
   else
     f = [f;-ones(1,columns(f))];
     npts = sum (ptsface = (sum (!! f)));
Index: main/vrml/inst/vrml_PointLight.m
===================================================================
--- main/vrml/inst/vrml_PointLight.m	(revision 7326)
+++ main/vrml/inst/vrml_PointLight.m	(revision 7327)
@@ -56,7 +56,7 @@
     elseif !(isnumeric(val) && isnan (val))
 
 				# Check validity of field
-    if ! struct_contains (tpl, key)
+    if ! isfield (tpl, key)
       error (sprintf ("vrml_PointLight : unknown field '%s'",key));
     end
 
@@ -67,7 +67,7 @@
   end
 end
 s = sprintf ("PointLight {\n%s}\n", body);
-if struct_contains (h,"DEF") && !isempty (h.DEF)
+if isfield (h,"DEF") && !isempty (h.DEF)
   s = ["DEF ",h.DEF," ",s];
 end 
 endfunction
Index: main/symbolic/src/symlsolve.cc
===================================================================
--- main/symbolic/src/symlsolve.cc	(revision 7326)
+++ main/symbolic/src/symlsolve.cc	(revision 7327)
@@ -46,7 +46,7 @@
 	}
 	
 	try {
-		if(args(0).is_list() || args(0).is_cell()) {
+		if(args(0).is_cell()) {
 			octave_value_list oct_eqn_list(args(0).list_value());
 			for(i=0;i<oct_eqn_list.length();i++) {
 				if(!get_relation(oct_eqn_list(i),relation)) {
@@ -67,7 +67,7 @@
 			eqns.append(relation);
 		}
 
-		if(args(1).is_list() || args(1).is_cell()) {
+		if(args(1).is_cell()) {
 			octave_value_list oct_vars(args(1).list_value());
 			for(i=0;i<oct_vars.length();i++) {
 				if(!get_symbol(oct_vars(i),expression)) {
Index: main/symbolic/src/symbols.cc
===================================================================
--- main/symbolic/src/symbols.cc	(revision 7326)
+++ main/symbolic/src/symbols.cc	(revision 7327)
@@ -373,7 +373,8 @@
 			gripe_wrong_type_arg ("subs",args(0));
 			return retval;
 		}
-		if (!(args(1).is_list() || args(1).is_cell())) {
+		//if (!(args(1).is_list() || args(1).is_cell())) {
+		if (!(args(1).is_cell())) {
 			if (!get_symbol (args(1), the_sym)) {
 				gripe_wrong_type_arg("subs",args(1));
 				return retval;
Index: main/symbolic/inst/symfsolve.m
===================================================================
--- main/symbolic/inst/symfsolve.m	(revision 7326)
+++ main/symbolic/inst/symfsolve.m	(revision 7327)
@@ -83,7 +83,7 @@
 					!strcmp(typeinfo(varargin{i}),"ex") )
 				break;
 			endif
-			eqns=append(eqns,varargin{i});
+			eqns{end+1} = varargin{i};
 			arg_count = arg_count+1;
 		endfor
 	endif
@@ -117,7 +117,7 @@
 		for i=(arg_count+1):2:nargin
 			tmp = disp(varargin{i});
 			if all(isalnum(tmp) | tmp=="_" | tmp==",")
-				vars=append(vars,varargin{i});
+				vars{end+1} = varargin{i};
 				X0((i-arg_count+1)/2)=varargin{i+1};
 			else
 				error("Error in symbol-value pair arguments.")
@@ -133,7 +133,7 @@
 			# cell-array of relations - this should work for a list of strings ("x==3") too.
 			for i=1:nvars
 				tmp = disp(varargin{arg_count+1}{i});
-				vars = append(vars,sym(strtok(tmp,"==")));
+				vars{end+1} = {sym(strtok(tmp,"=="))};
 				X0(i) = str2num(tmp((findstr(tmp,"==")+2):length(tmp)));
 			endfor
 		else
Index: main/vrml/inst/vrml_TimeSensor.m
===================================================================
--- main/vrml/inst/vrml_TimeSensor.m	(revision 7335)
+++ main/vrml/inst/vrml_TimeSensor.m	(revision 7336)
@@ -104,11 +104,34 @@
 
       if verbose, printf ("vrml_TimeSensor : Trying to learn type of node\n"); end
 
-      if isfield (dnode, k)
+      if iscell (v)		# v is list of arguments
+
+				# Check whether 1st arg is node type's name.
+        n = v{1};
+
+	if all (exist (["vrml_",tn]) != [2,3,5])
+	  			# If it isn't type's name, use default type.
+	  if isfield (dnode, k)
+	    if verbose
+	      printf ("vrml_TimeSensor : Using default type : %s\n",getfield(dnode,k));
+	    end
+	    v = {getfield(dnode,k), v{:}};
+	  else
+	    error ("vrml_TimeSensor : Can't determine type of node '%s'",k);
+	  end
+	else
+	  if verbose
+            printf ("vrml_TimeSensor : 1st list element is type : %s\n",tn);
+	  end
+	end
+				# If v is not a list, maybe it has a default
+				# node type type (otherwise, it's be sent
+				# plain.
+      elseif isfield (dnode, k)
 	if verbose
 	  printf ("vrml_TimeSensor : Using default type : %s\n",dnode.(k));
 	end
-	v = {getfield(dnode,k), v};
+	v = {getfield(dnode,k), v{:}};
       end
     end
     l = {l{:}, k, " ", data2vrml(getfield(tpl,k),v),"\n"};
------------------------------------------------------------------------------

_______________________________________________
Octave-dev mailing list
Octave-dev@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/octave-dev

Reply via email to