diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2017-02-15 19:22:46 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2017-02-15 19:22:46 -0800 |
commit | dc0ecebee11c7dc7a8650efd2f8537cb1a869ad4 (patch) | |
tree | 3f5e1120c5282a509ed81d2f3503c98d4b2d181c | |
parent | e7831ed8f0b67b463be1e01e6c0254fb98d13848 (diff) | |
download | txr-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.c | 22 | ||||
-rw-r--r-- | lib.h | 1 |
2 files changed, 23 insertions, 0 deletions
@@ -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); @@ -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); |