![]() ![]() | lists.c - Funktionerne cons, head og tail. | Lektion 9 - slide 20 : 29 Program 1 |
/* Returns a pointer to a new cons cell, which refers data and next via pointers*/ cons_cell *cons(void *data, cons_cell *next){ cons_cell *result; result = malloc(sizeof(cons_cell)); result->data = data; result->next = next; return result; } /* Return the head reference of the cons cell */ void *head(cons_cell *cell){ return cell->data; } /* Return the tail refererence f the cons cell */ cons_cell *tail(cons_cell *cell){ return cell->next; }