intGListDepth1(GList L){//按表头表尾求广义表深度 /* Return the depth of list */int h1,h2;if(NULL==L)return1;if(ATOM==L->tag)return0;
h1 =GListDepth1(L->un.ptr.hp)+1;
h2 =GListDepth1(L->un.ptr.tp);return h1>=h2?h1:h2;
元素分解求深度
intGListDepth2(GList L){//元素分解求深度 int dep,max;
GLNode *p;if(NULL==L)return1;elseif(ATOM==L->tag)return0;for(max =0,p=L;p!=NULL;p=p->un.ptr.tp){
dep =GListDepth2(p->un.ptr.hp);if(dep>max)
max = dep;}return max+1;}
按表头表尾分解求长度
intGListLength1(GList L){//按表头表尾分解求长度 int len =0; GLNode *p;if(NULL==L)return len;for(len =1,p = L->un.ptr.tp;p!=NULL; p = p->un.ptr.tp)
len++;return len;}
按元素分解广义表求解长度
intGListLength2(GList L){//按元素分解广义表求解广义表长度 int len;if(NULL==L)
len =0;//空表长度为0elseif(NULL==L->un.ptr.tp)
len =1;else
len =GListLength2(L->un.ptr.tp)+1;return len;