code: def getList(x):
      
  
      t = PL_copy_term_ref(x)
      head = PL_new_term_ref()
      result = []
      while PL_get_list(t, head, t):
          result.append(getTerm(head))
          head = PL_new_term_ref()
  
      return result
docs: Return t as a list.