Guest User

Untitled

a guest
Jun 24th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.51 KB | None | 0 0
  1. ilist iappend_destroy(ilist il1, ilist il2){
  2.     if(!il1) return il2; // so the following "while" is correct
  3.     int lengthToAdd = ilength(il2);  //   <- new
  4.     ilist temp = il1;
  5.     while(temp->rest) {
  6.         temp->length+=lengthToAdd; //   <- new
  7.         temp = temp->rest;
  8.     }
  9.     // now temp points to the last entry of il1
  10.     while(il2) {
  11.         temp->rest = il2;
  12.         temp = temp->rest;
  13.         il2 = il2->rest;
  14.     }
  15.     // now every node of il2 is appended to il1 and we just need to append the finishing null
  16.     temp->rest = 0;
  17.     return il1;
  18. }
Add Comment
Please, Sign In to add comment