-#include <assert.h>
-#include <gsl/gsl_math.h>
-#include <gsl/gsl_vector.h>
-#include <data/value.h>
-#include <data/variable.h>
-#include <math/interaction.h>
-#include <string.h>
-#include <xalloc.h>
-
-struct interaction_variable
+
+#include "data/case.h"
+#include "interaction.h"
+
+#include "data/value.h"
+#include "data/variable.h"
+#include "libpspp/str.h"
+
+#include "gl/xalloc.h"
+
+#include <stdio.h>
+
+/* Creates and returns an interaction. If V is nonnull, then the interaction
+ initially contains V, otherwise it is initially empty. */
+struct interaction *
+interaction_create (const struct variable *v)
+{
+ struct interaction *iact = xmalloc (sizeof *iact);
+ iact->vars = xmalloc (sizeof *iact->vars);
+ iact->n_vars = 0;
+ if ( v )
+ {
+ iact->vars[0] = v;
+ iact->n_vars = 1;
+ }
+ return iact;
+}
+
+/* Returns a (deep) copy of interaction SRC. */
+struct interaction *
+interaction_clone (const struct interaction *src)
+{
+ struct interaction *dst = xmalloc (sizeof *dst);
+ dst->vars = xmemdup (src->vars, src->n_vars * sizeof *src->vars);
+ dst->n_vars = src->n_vars;
+ return dst;
+}
+
+/* Frees IACT. */
+void
+interaction_destroy (struct interaction *iact)
+{
+ if (iact)
+ {
+ free (iact->vars);
+ free (iact);
+ }
+}
+
+/* Appends variable V to IACT.
+
+ V must not already be in IACT. */
+void
+interaction_add_variable (struct interaction *iact, const struct variable *v)