[PD-cvs] pd/src x_list.c,1.2.2.9.2.2,1.2.2.9.2.3

Mathieu Bouchard matju at users.sourceforge.net
Fri Dec 8 07:41:57 CET 2006


Update of /cvsroot/pure-data/pd/src
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20161

Modified Files:
      Tag: desiredata
	x_list.c 
Log Message:
0.40


Index: x_list.c
===================================================================
RCS file: /cvsroot/pure-data/pd/src/x_list.c,v
retrieving revision 1.2.2.9.2.2
retrieving revision 1.2.2.9.2.3
diff -C2 -d -r1.2.2.9.2.2 -r1.2.2.9.2.3
*** x_list.c	8 Dec 2006 04:33:37 -0000	1.2.2.9.2.2
--- x_list.c	8 Dec 2006 06:41:55 -0000	1.2.2.9.2.3
***************
*** 31,45 ****
      list trim - trim off "list" selector
      list length - output number of items in list
-     list nth - nth item in list, counting from zero
  
! Not sure we need these:
!     list cat - build a list by accumulating elements
!     list foreach - spit out elements of a list one by one
      list array - get items from a named array as a list
      list reverse - permute elements of a list back to front
      list pack - synonym for 'pack'
      list unpack - synonym for 'unpack'
      list first - output first n elements.
      list last - output last n elements
  */
  
--- 31,47 ----
      list trim - trim off "list" selector
      list length - output number of items in list
  
! Need to think more about:
!     list foreach - spit out elements of a list one by one (also in reverse?)
      list array - get items from a named array as a list
      list reverse - permute elements of a list back to front
      list pack - synonym for 'pack'
      list unpack - synonym for 'unpack'
+     list cat - build a list by accumulating elements
+ 
+ Probably don't need:
      list first - output first n elements.
      list last - output last n elements
+     list nth - nth item in list, counting from zero
  */
  
***************
*** 392,395 ****
--- 394,435 ----
  }
  
+ /* ------------- list length --------------------- */
+ 
+ t_class *list_length_class;
+ 
+ typedef struct _list_length
+ {
+     t_object x_obj;
+ } t_list_length;
+ 
+ static void *list_length_new( void)
+ {
+     t_list_length *x = (t_list_length *)pd_new(list_length_class);
+     outlet_new(&x->x_obj, &s_float);
+     return (x);
+ }
+ 
+ static void list_length_list(t_list_length *x, t_symbol *s,
+     int argc, t_atom *argv)
+ {
+     outlet_float(x->x_obj.ob_outlet, (float)argc);
+ }
+ 
+ static void list_length_anything(t_list_length *x, t_symbol *s,
+     int argc, t_atom *argv)
+ {
+     outlet_float(x->x_obj.ob_outlet, (float)argc+1);
+ }
+ 
+ static void list_length_setup(void)
+ {
+     list_length_class = class_new(gensym("list length"),
+         (t_newmethod)list_length_new, 0,
+         sizeof(t_list_length), 0, 0);
+     class_addlist(list_length_class, list_length_list);
+     class_addanything(list_length_class, list_length_anything);
+     class_sethelpsymbol(list_length_class, &s_list);
+ }
+ 
  /* ------------- list ------------------- */
  
***************
*** 410,413 ****
--- 450,455 ----
           else if (s2 == gensym("trim"))
              newest = list_trim_new();
+          else if (s2 == gensym("length"))
+             newest = list_length_new();
          else 
          {
***************
*** 428,431 ****
--- 470,474 ----
      list_split_setup();
      list_trim_setup();
+     list_length_setup();
      class_addcreator((t_newmethod)list_new, &s_list, A_GIMME, 0);
  }





More information about the Pd-cvs mailing list