diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2019-06-25 07:16:03 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2019-06-25 07:16:03 -0700 |
commit | f30990943abba9a73bf0f2396c996c612e7862d3 (patch) | |
tree | 0d9bccc53f2aa3a1763aa325b5c44f9b1dffbac6 /lib.c | |
parent | 988b2b2f018e02c02bf60fb93c4fa24a880b5a26 (diff) | |
download | txr-f30990943abba9a73bf0f2396c996c612e7862d3.tar.gz txr-f30990943abba9a73bf0f2396c996c612e7862d3.tar.bz2 txr-f30990943abba9a73bf0f2396c996c612e7862d3.zip |
list_collect: handle objects.
* lib.c (list_collect): Handle sequence-like COBJ objects.
We can add an item to using their respective replace
functions.
(replace_obj): Change to external linkage.
* lib.h (replace_obj): Declared.
Diffstat (limited to 'lib.c')
-rw-r--r-- | lib.c | 11 |
1 files changed, 10 insertions, 1 deletions
@@ -1047,6 +1047,15 @@ loc list_collect(loc ptail, val obj) case LSTR: replace_str(tailobj, items, t, t); return ptail; + case COBJ: + if (tailobj->co.cls == carray_s) { + carray_replace(tailobj, items, t, t); + return ptail; + } + if (obj_struct_p(tailobj)) { + replace_obj(tailobj, items, t, t); + return ptail; + } default: uw_throwf(error_s, lit("cannot append ~s"), deref(ptail), nao); } @@ -7277,7 +7286,7 @@ val replace_vec(val vec_in, val items, val from, val to) return vec_in; } -static val replace_obj(val obj, val items, val from, val to) +val replace_obj(val obj, val items, val from, val to) { val self = lit("replace"); val lambda_set_meth = maybe_slot(obj, lambda_set_s); |