So, I'm diving into C and decided to create cons cells. I'd like some thoughts on style and correctness. There are no warnings with `-Wall -g` and Valgrind doesn't complain about anything.

I'm really not sure what to do when the list is `NULL` in the `first` function.

```
#include <stdio.h>
#include <stdlib.h>

struct Cell {
    int val;
    struct Cell *next;
};

struct Cell *cons(int val, struct Cell *rest)
{
    struct Cell *cell = malloc(sizeof(struct Cell));
    cell->val = val;
    cell->next = rest;
    return cell;
}

int first(struct Cell *list)
{
    if (list) {
        return list->val;
    }
    return 0;
}

struct Cell *rest(struct Cell *list)
{
    return list->next;
}

int length(struct Cell *list)
{
    if (list) {
        return 1 + length(rest(list));
    }
    return 0;
}

void destroy(struct Cell *list)
{
    if (list) {
        destroy(rest(list));
        free(list);
    }
}

void print(struct Cell *list)
{
    if (list) {
        printf("%d\n", first(list));
        print(rest(list));
    }
}

```

The main function.

```
int main(int argc, char *argv[])
{
    struct Cell *list = NULL;
    int i;
    for (i = 1; i < argc; ++i) {
        list = cons(atoi(argv[i]), list);
    }
    puts("Entire list:");
    print(list);
    puts("First:");
    printf("%d\n", first(list));
    puts("Rest:");
    print(rest(list));
    puts("Length:");
    printf("%d\n", length(list));
    destroy(list);
    return 0;
}

```

Running it.

```
./cons 1 2 3 4

```