about summary refs log tree commit diff
path: root/usth/ICT2.1/labwork/4/construct.c
diff options
context:
space:
mode:
Diffstat (limited to 'usth/ICT2.1/labwork/4/construct.c')
-rw-r--r--usth/ICT2.1/labwork/4/construct.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/usth/ICT2.1/labwork/4/construct.c b/usth/ICT2.1/labwork/4/construct.c
new file mode 100644
index 0000000..887b6d8
--- /dev/null
+++ b/usth/ICT2.1/labwork/4/construct.c
@@ -0,0 +1,26 @@
+/*
+ * Lisp construct implementation.
+ * This is free and unencumbered software released into the public domain.
+ */
+
+#include <stdlib.h>
+
+#include "construct.h"
+
+construct *cons(void *first, construct *rest)
+{
+	construct *list = malloc(sizeof(construct));
+	list->car = first;
+	list->cdr = rest;
+	return list;
+}
+
+void *car(construct *list)
+{
+	return list->car;
+}
+
+construct *cdr(construct *list)
+{
+	return list->cdr;
+}