summaryrefslogtreecommitdiff
path: root/examples/list_null.c
diff options
context:
space:
mode:
authorTom Harley2019-12-23 01:32:39 +0000
committerTom Harley2019-12-23 01:32:39 +0000
commit7bc67b95161a34f8eca635d4000d9602508a9243 (patch)
tree585b3778dc1967832390e5829e4b3909b4184a2c /examples/list_null.c
parentAdd basics for interpreter; add CLI options (diff)
downloadsinter-7bc67b95161a34f8eca635d4000d9602508a9243.tar.gz
sinter-7bc67b95161a34f8eca635d4000d9602508a9243.zip

checkpoint

Diffstat (limited to 'examples/list_null.c')
-rw-r--r--examples/list_null.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/examples/list_null.c b/examples/list_null.c
new file mode 100644
index 0000000..85a3d2c
--- /dev/null
+++ b/examples/list_null.c
@@ -0,0 +1,27 @@
+typedef struct list_t {
+ void *content;
+ struct list_t *next;
+} list_t;
+
+void *list(void *head, void *tail) {
+ list_t *ret = gc_alloc(sizeof (*ret));
+ ret->content = head;
+ ret->next = (list_t *) tail;
+ return ret;
+}
+
+void *nil() {
+ return (void *) 0;
+}
+
+void *head(void *list) {
+ return list->head;
+}
+
+void *tail(void *list) {
+ return list->tail;
+}
+
+void *has_tail(void *list) {
+ return list->tail;
+}