summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2017-02-15 19:22:46 -0800
committerKaz Kylheku <kaz@kylheku.com>2017-02-15 19:22:46 -0800
commitdc0ecebee11c7dc7a8650efd2f8537cb1a869ad4 (patch)
tree3f5e1120c5282a509ed81d2f3503c98d4b2d181c
parente7831ed8f0b67b463be1e01e6c0254fb98d13848 (diff)
downloadtxr-dc0ecebee11c7dc7a8650efd2f8537cb1a869ad4.tar.gz
txr-dc0ecebee11c7dc7a8650efd2f8537cb1a869ad4.tar.bz2
txr-dc0ecebee11c7dc7a8650efd2f8537cb1a869ad4.zip
New internal function: vec.
* lib.c (vec): New function. * lib.h (vec): Declared.
-rw-r--r--lib.c22
-rw-r--r--lib.h1
2 files changed, 23 insertions, 0 deletions
diff --git a/lib.c b/lib.c
index 98e80315..22135f89 100644
--- a/lib.c
+++ b/lib.c
@@ -6668,6 +6668,28 @@ val vectorv(struct args *args)
return vec;
}
+val vec(val first, ...)
+{
+ va_list vl;
+ val vec = vector(zero, nil);
+ val next;
+ int count;
+
+ va_start (vl, first);
+
+ for (next = first, count = 0;
+ next != nao && count < 32;
+ next = va_arg(vl, val), count++)
+ {
+ vec_push(vec, next);
+ }
+
+ if (count == 32 && next != nao)
+ internal_error("runaway arguments in vec function");
+
+ return vec;
+}
+
val vec_list(val list)
{
val vec = vector(zero, nil);
diff --git a/lib.h b/lib.h
index 5f44eb41..2e374e7c 100644
--- a/lib.h
+++ b/lib.h
@@ -893,6 +893,7 @@ val vec_push(val vec, val item);
val length_vec(val vec);
val size_vec(val vec);
val vectorv(struct args *);
+val vec(val first, ...);
val vec_list(val list);
val list_vec(val vector);
val copy_vec(val vec);