From 9ec47b693f9618bfd29347226157dc2f8a655ff8 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Sun, 22 Aug 2021 11:18:19 -0700 Subject: iter-begin: allow iterator argument. * lib.c (seq_iter_init_with_info): Allow the iterated object to be an iterator, in which case a copy of the iterator is set up. * txr.1: Documented. --- lib.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'lib.c') diff --git a/lib.c b/lib.c index 628ed06e..6175497f 100644 --- a/lib.c +++ b/lib.c @@ -987,6 +987,11 @@ void seq_iter_init_with_info(val self, seq_iter_t *it, } } } + if (it->inf.obj->co.cls == seq_iter_cls) + { + *it = *coerce(struct seq_iter *, it->inf.obj->co.handle); + break; + } if (it->inf.obj->co.cls == tree_iter_cls) { it->ui.iter = if3(support_rewind, -- cgit v1.2.3