work on type inference some more
[ccc.git] / list.h
1 #ifndef LIST_H
2 #define LIST_H
3
4 #include <stdbool.h>
5
6 #define FOREACH(x, l) for(struct list *x = l; x != NULL; x = x->tail)
7
8 struct list {
9 void *el;
10 struct list *tail;
11 };
12
13 struct list *list_append(void *el, struct list *head);
14 struct list *list_cons(void *el, struct list *tail);
15 void list_free(struct list *head, void (*freefun)(void *));
16 void **list_to_array(struct list *list, int *num, bool reverse);
17 int list_length(struct list *head);
18
19 #endif