next up previous
Next: 4.3.4 member Up: 4.3 Car, Cdr Previous: 4.3.2 list

4.3.3 append


LVAL xappend()
{
  LVAL list,last,next,val;
  
  /* protect some pointers */
  xlsave1(val);
  
  /* initialize */
  val = NIL;
  
  /* append each argument */
  if (moreargs()) {
    while (xlargc > 1) {
      
      /* append each element of
         this list to the result list */
      for (list = nextarg();
           consp(list);
           list = cdr(list)) {
        next = consa(car(list));
        if (val) rplacd(last,next);
        else val = next;
        last = next;
      }
    }
    
    /* handle the last argument */
    if (val) rplacd(last,nextarg());
    else val = nextarg();
  }
  
  /* restore the stack */
  xlpop();
  
  /* return the list */
  return (val);
}


generated through LaTeX2HTML. M.Inaba 平成18年5月6日