1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <assert.h>

// NAÏVE WAY - do not do it like this
//
// Wastes lots of space, and we don't know what kind of data a given
// node contains.


// This declares a type, and three constants

struct Node {
    struct Node* next;
    int    as_int;
    char*  as_string;
    struct Node* as_list;
    enum NodeType { NODE_INT, NODE_STRING, NODE_LIST } type;  // best
};

/* vim: set tabstop=4 shiftwidth=4 fileencoding=utf-8 noexpandtab: */

© Copyright 2020 Alexander J. Quinn         This content is protected and may not be shared, uploaded, or distributed.