1: #ifndef lint
   2: static char sccsid[] = "@(#)0.list.c	4.1	(Berkeley)	2/11/83";
   3: #endif not lint
   4: 
   5: #include <stdio.h>
   6: #include "def.h"
   7: 
   8: struct list *consls(v,ls)       /* make list */
   9: VERT v;
  10: struct list *ls;
  11:     {
  12:     struct list *temp;
  13:     temp = challoc(sizeof(*temp));
  14:     temp->elt = v;
  15:     temp->nxtlist = ls;
  16:     return(temp);
  17:     }
  18: 
  19: struct list *append(v,ls)       /* return ls . v */
  20: VERT v;
  21: struct list *ls;
  22:     {
  23:     struct list *temp;
  24:     if (!ls) return(consls(v,0));
  25:     for (temp = ls; temp -> nxtlist; temp = temp->nxtlist)
  26:         ;
  27:     temp->nxtlist = consls(v,0);
  28:     return(ls);
  29:     }
  30: 
  31: 
  32: freelst(ls)
  33: struct list *ls;
  34:     {
  35:     if (!ls) return;
  36:     if (ls->nxtlist)
  37:         freelst(ls->nxtlist);
  38:     chfree(ls,sizeof(*ls));
  39:     }
  40: 
  41: 
  42: oneelt(ls)      /* return w if w is only elt of ls, UNDEFINED otherwise */
  43: struct list *ls;
  44:     {
  45:     if (!ls) return(UNDEFINED);
  46:     if (ls->nxtlist) return(UNDEFINED);
  47:     return(ls->elt);
  48:     }
  49: 
  50: 
  51: lslen(ls)       /* return number of elements in list ls */
  52: struct list *ls;
  53:     {
  54:     int count;
  55:     struct list *lp;
  56:     count = 0;
  57:     for (lp = ls; lp; lp = lp->nxtlist)
  58:         ++count;
  59:     return(count);
  60:     }
  61: 
  62: 
  63: prlst(ls)
  64: struct list *ls;
  65:     {
  66:     struct list *lp;
  67:     for (lp = ls; lp; lp = lp->nxtlist)
  68:         printf("%d,",lp->elt);
  69:     fprintf(stderr,"\n");
  70:     }

Defined functions

append defined in line 19; used 3 times
consls defined in line 8; used 3 times
freelst defined in line 32; used 4 times
lslen defined in line 51; used 1 times
oneelt defined in line 42; used 1 times
prlst defined in line 63; never used

Defined variables

sccsid defined in line 2; never used
Last modified: 1983-02-12
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 981
Valid CSS Valid XHTML 1.0 Strict