diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2023-09-30 12:33:54 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2023-09-30 12:33:54 -0700 |
commit | 4a4c01a1753a502268a0611fdff3aaa054791670 (patch) | |
tree | d7f234bf224f5ce4d7115073ecb1f35fd3179b88 /tests/012/oop.tl | |
parent | 9b5c23e7c88535f49dfbc8d5028ff5c82704435a (diff) | |
download | txr-4a4c01a1753a502268a0611fdff3aaa054791670.tar.gz txr-4a4c01a1753a502268a0611fdff3aaa054791670.tar.bz2 txr-4a4c01a1753a502268a0611fdff3aaa054791670.zip |
flatten*: fix two bugs.
* lib.c (lazy_flatten_scan): Fix a problem which results
in cases like (()), ((())) ... to incorrectly flatten
to (nil). The do loop in this function which iteratively
descends into a nested left-nesting of a list does not handle
all cases, and therefore the function may not return at that
point. Removing the return fixes the problem, but so does
removing the loop so that in that case we just descend one
level into the nested list, and continue in the main loop.
What is incorrect is that when the consp(a) test fails and the
do loop terminates, we need to distinguish the cases off
a being an atom versus nil. Continuing in the loop does that.
This bug was spotted by a reviewer in the comp.lang.c
Usenet newsgroup.
(lazy_flatten): We neglect to handle the case here that
the input is an empty list, resulting in (flatten* nil)
returning (nil) rather than nil. The flatten function
is correct.
* tests/012/seq.tl: New tests.
* txr.1: Documentation improved. In particular, these
functions don't handle improper lists. Also, it needs
to be documented that the argument may be an atom.
Diffstat (limited to 'tests/012/oop.tl')
0 files changed, 0 insertions, 0 deletions