version 1.4, 2004/09/09 11:42:22 |
version 1.8, 2020/10/06 11:33:46 |
|
|
/* $OpenXM: OpenXM/src/kan96xx/Kan/list.c,v 1.3 2001/05/04 01:06:24 takayama Exp $ */ |
/* $OpenXM: OpenXM/src/kan96xx/Kan/list.c,v 1.7 2005/07/03 11:08:54 ohara Exp $ */ |
/* list.c */ |
/* list.c */ |
#include <stdio.h> |
#include <stdio.h> |
|
#include <stdlib.h> |
#include "datatype.h" |
#include "datatype.h" |
#include "stackm.h" |
#include "stackm.h" |
#include "extern.h" |
#include "extern.h" |
|
|
static errorList(char *s); |
static void errorList(char *s); |
static warningList(char *s); |
static void warningList(char *s); |
|
|
/* The basic data structure for list is |
/* The basic data structure for list is |
struct object *, |
struct object *, |
Line 27 struct object *newList(objp) |
|
Line 28 struct object *newList(objp) |
|
/* Warning!! Make a copy of the object. It is important. */ |
/* Warning!! Make a copy of the object. It is important. */ |
*(op->lc.op) = *(objp); |
*(op->lc.op) = *(objp); |
op->rc.op = (struct object *)NULL; |
op->rc.op = (struct object *)NULL; |
|
op->attr = NULL; |
return(op); |
return(op); |
} |
} |
|
|
Line 48 struct object listToArray(objp) |
|
Line 50 struct object listToArray(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 = OINIT; |
int i; |
int i; |
if (objp->tag != Slist) { |
if (objp->tag != Slist) { |
warningList("use objectListToObjectArray() for object-list."); |
warningList("use objectListToObjectArray() for object-list."); |
Line 136 struct object *cdr(list) |
|
Line 138 struct object *cdr(list) |
|
} |
} |
|
|
|
|
void printObjectList(op) |
static void printObjectList0(op,br) |
struct object *op; |
struct object *op; int br; |
{ |
{ |
if (op == NULL) return; |
if (op == NULL) return; |
if (isNullList(op)) return; |
if (isNullList(op)) return; |
if (op->tag == Slist) { |
if (op->tag == Slist) { |
printObjectList(op->lc.op); |
if (br) printf("<"); |
|
printObjectList0(op->lc.op,1); |
printf(", "); |
printf(", "); |
printObjectList(op->rc.op); |
printObjectList0(op->rc.op,0); |
|
if (br) printf(">"); |
}else { |
}else { |
printObject(*op,0,stdout); |
printObject(*op,0,stdout); |
} |
} |
} |
} |
|
|
memberQ(list1,obj2) |
void printObjectList(op) |
|
struct object *op; |
|
{ |
|
printObjectList0(op,1); |
|
} |
|
|
|
int 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. |
Line 167 memberQ(list1,obj2) |
|
Line 177 memberQ(list1,obj2) |
|
return(0); |
return(0); |
} |
} |
|
|
static errorList(str) |
static void 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 void warningList(str) |
char *str; |
char *str; |
{ |
{ |
fprintf(stderr,"Warning. list.c: %s\n",str); |
fprintf(stderr,"Warning. list.c: %s\n",str); |
} |
} |
|
|
struct object KvJoin(struct object listo1,struct object listo2) { |
struct object KvJoin(struct object listo1,struct object listo2) { |
struct object rob; |
struct object rob = OINIT; |
struct object *op1,*op2; |
struct object *op1,*op2; |
if (listo1.tag == Snull) return listo2; |
if (listo1.tag == Snull) return listo2; |
if (listo2.tag == Snull) return listo1; |
if (listo2.tag == Snull) return listo1; |
Line 206 struct object Kcar(struct object listo) { |
|
Line 216 struct object Kcar(struct object listo) { |
|
} |
} |
struct object Kcdr(struct object listo) { |
struct object Kcdr(struct object listo) { |
struct object *op; |
struct object *op; |
struct object rob; |
struct object rob = OINIT; |
if (listo.tag == Snull) return listo; |
if (listo.tag == Snull) return listo; |
if (listo.tag == Slist) { |
if (listo.tag == Slist) { |
op = cdr(&listo); |
op = cdr(&listo); |