struct List {
  int head;
  struct List* tail;
};

typedef struct List list;


/* convert an array A to a list. */
list* array2list(int? A) {
  list* l = NULL;
  int i;   int n = numelts(A);
  if (!A) return NULL;
  for (i = n - 1; i >= 0; i--) {
    list* t = malloc (sizeof (list));

    t->head = A[i];
    t->tail = l;
    l = t;
  }

  return l;
}
