summaryrefslogtreecommitdiff
path: root/misc.c
diff options
context:
space:
mode:
Diffstat (limited to 'misc.c')
-rw-r--r--misc.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/misc.c b/misc.c
index dcd5e17..28ba45c 100644
--- a/misc.c
+++ b/misc.c
@@ -5,6 +5,20 @@
#include "fns.h"
Term *
+copyterm(Term *orig)
+{
+ Term *new = malloc(sizeof(Term));
+ memcpy(new, orig, sizeof(Term));
+ new->next = nil;
+ new->children = nil;
+
+ Term *child;
+ for(child = orig->children; child != nil; child = child->next)
+ new->children = appendterm(new->children, copyterm(child));
+ return new;
+}
+
+Term *
appendterm(Term *a, Term *b)
{
if(a == nil)