Advertisement
Guest User

Untitled

a guest
Sep 25th, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.45 KB | None | 0 0
  1. struct Elem *searchlist(struct Elem* list, int k)
  2. {
  3.     while (list != NULL)
  4.     {
  5.         if (list->tag == INTEGER)
  6.         {
  7.             if (list->value.i == k)
  8.                 return list;
  9.         }
  10.         else if (list->tag == LIST)
  11.         {
  12.             struct Elem* result = searchlist(list->value.list, k);
  13.             if (result != NULL)
  14.                 return result;
  15.         }
  16.  
  17.         list = list->tail;
  18.     }
  19.  
  20.     return list;
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement