[BACK]Return to list.c CVS log [TXT][DIR] Up to [local] / OpenXM / src / kan96xx / Kan

Diff for /OpenXM/src/kan96xx/Kan/list.c between version 1.2 and 1.3

version 1.2, 2000/01/16 07:55:39 version 1.3, 2001/05/04 01:06:24
Line 1 
Line 1 
 /* $OpenXM$ */  /* $OpenXM: OpenXM/src/kan96xx/Kan/list.c,v 1.2 2000/01/16 07:55:39 takayama Exp $ */
 /* list.c */  /* list.c */
 #include <stdio.h>  #include <stdio.h>
 #include "datatype.h"  #include "datatype.h"
Line 16  static warningList(char *s);
Line 16  static warningList(char *s);
 */  */
   
 struct object *newList(objp)  struct object *newList(objp)
 struct object *objp;       struct object *objp;
 {  {
   struct object *op;    struct object *op;
   op = (struct object *)sGC_malloc(sizeof(struct object));    op = (struct object *)sGC_malloc(sizeof(struct object));
Line 31  struct object *objp;
Line 31  struct object *objp;
 }  }
   
 int klength(objp)  int klength(objp)
 struct object *objp;       struct object *objp;
 {  {
   if (objp->tag != Slist) {    if (objp->tag != Slist) {
     warningList("use klength() for object-list.");      warningList("use klength() for object-list.");
Line 44  struct object *objp;
Line 44  struct object *objp;
 }  }
   
 struct object listToArray(objp)  struct object listToArray(objp)
 struct object *objp;       struct object *objp;
 /* This function copies only the top level of the list */       /* This function copies only the top level of the list */
 {  {
   int n;    int n;
   struct object ans;    struct object ans;
Line 66  struct object *objp;
Line 66  struct object *objp;
 }  }
   
 struct object *arrayToList(obj)  struct object *arrayToList(obj)
 struct object obj;       struct object obj;
 /* obj.tag must be Sarray */       /* obj.tag must be Sarray */
 {  {
   struct object *op;    struct object *op;
   struct object *list;    struct object *list;
Line 85  struct object obj;
Line 85  struct object obj;
 }  }
   
 struct object *vJoin(list1,list2)  struct object *vJoin(list1,list2)
 struct object *list1,*list2;       struct object *list1,*list2;
 /* Join[(a b), (c d)] ---> (a b c d) */       /* Join[(a b), (c d)] ---> (a b c d) */
 /* Join [(),(a b)] ---> (a b) */       /* Join [(),(a b)] ---> (a b) */
 /* We do not copy. NullList is express by (struct object *)NULL.       /* We do not copy. NullList is express by (struct object *)NULL.
    cf. isNullList()          cf. isNullList()
 */       */
 {  {
   /*    /*
   printf("list1=");  printObjectList(list1);      printf("list1=");  printObjectList(list1);
   printf("\nlist2=");  printObjectList(list2);  printf("\n");      printf("\nlist2=");  printObjectList(list2);  printf("\n");
   */    */
   
   if (isNullList(list1)) return(list2);    if (isNullList(list1)) return(list2);
Line 113  struct object *list1,*list2;
Line 113  struct object *list1,*list2;
 }  }
   
 struct object car(list)  struct object car(list)
 struct object *list;       struct object *list;
 {  {
   if (list->tag != Slist) {    if (list->tag != Slist) {
     warningList("car() is called for a non-list object.");      warningList("car() is called for a non-list object.");
Line 125  struct object *list;
Line 125  struct object *list;
 }  }
   
 struct object *cdr(list)  struct object *cdr(list)
 struct object *list;       struct object *list;
 {  {
   if (list->tag != Slist) {    if (list->tag != Slist) {
     warningList("cdr() is called for a non-list object.");      warningList("cdr() is called for a non-list object.");
Line 137  struct object *list;
Line 137  struct object *list;
   
   
 void printObjectList(op)  void printObjectList(op)
 struct object *op;       struct object *op;
 {  {
   if (op == NULL) return;    if (op == NULL) return;
   if (isNullList(op)) return;    if (isNullList(op)) return;
Line 151  struct object *op;
Line 151  struct object *op;
 }  }
   
 memberQ(list1,obj2)  memberQ(list1,obj2)
 struct object *list1;       struct object *list1;
 struct object obj2;       struct object obj2;
 /* If obj2 is an member of list1, the functions the position.       /* If obj2 is an member of list1, the functions the position.
    memberQ( (1 (2 3) 4), 4) ----> 3.     memberQ( (1 (2 3) 4), 4) ----> 3.
 */  */
 {  {
Line 168  struct object obj2;
Line 168  struct object obj2;
 }  }
   
 static errorList(str)  static errorList(str)
 char *str;       char *str;
 {  {
   fprintf(stderr,"list.c: %s\n",str);    fprintf(stderr,"list.c: %s\n",str);
   exit(10);    exit(10);
 }  }
   
 static warningList(str)  static warningList(str)
 char *str;       char *str;
 {  {
   fprintf(stderr,"Warning. list.c: %s\n",str);    fprintf(stderr,"Warning. list.c: %s\n",str);
 }  }
Line 183  char *str;
Line 183  char *str;
   
 /********************** test codes for Stest: ********************/  /********************** test codes for Stest: ********************/
 /* test of objectArrayToObjectList. in Stest: stackmachine.c  /* test of objectArrayToObjectList. in Stest: stackmachine.c
     {     {
       struct object *list;     struct object *list;
       list = arrayToList(ob1);     list = arrayToList(ob1);
       ob1 = listToArray(list);     ob1 = listToArray(list);
       push(ob1);     push(ob1);
     }     }
     test for memberQ().     test for memberQ().
     {     {
       struct object *list;     struct object *list;
       list = objectArrayToObjectList(pop());     list = objectArrayToObjectList(pop());
       printf("\nmemberQ()=%d\n",memberQ(list,ob1));     printf("\nmemberQ()=%d\n",memberQ(list,ob1));
     }     }
   
 */  */

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>