summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2016-06-01 20:35:54 -0700
committerKaz Kylheku <kaz@kylheku.com>2016-06-01 20:35:54 -0700
commita59ea34c87c2554bcbb95a083ee6fb04a53f2963 (patch)
treea1f7bd79d3dba7b5e87d1fbb1e107136ec2a77e3
parenta844fe6d05410998d1869ad111be3c0e3706dd5e (diff)
downloadtxr-a59ea34c87c2554bcbb95a083ee6fb04a53f2963.tar.gz
txr-a59ea34c87c2554bcbb95a083ee6fb04a53f2963.tar.bz2
txr-a59ea34c87c2554bcbb95a083ee6fb04a53f2963.zip
ldiff uses equal for all non-list arguments.
* lib.c (ldiff): Rather than checking specifically for strings and vectors to apply the special case behavior (comparison using equal), test specifically for lists and apply the traditional behavior. Every other object, not just strings and vectors, gets the altered behavior. * txr.1: Changed text in TXR Lisp introduction which touches on ldiff, and wording fix under ldiff.
-rw-r--r--lib.c11
-rw-r--r--txr.16
2 files changed, 8 insertions, 9 deletions
diff --git a/lib.c b/lib.c
index 92d218a6..cfa2d2bb 100644
--- a/lib.c
+++ b/lib.c
@@ -1298,17 +1298,16 @@ val ldiff(val list1, val list2)
list2 = nullify(list2);
switch (type(list2)) {
- case STR:
- case LIT:
- case LSTR:
- case VEC:
- while (list1 && !equal(list1, list2)) {
+ case NIL:
+ case CONS:
+ case LCONS:
+ while (list1 && list1 != list2) {
ptail = list_collect(ptail, car(list1));
list1 = cdr(list1);
}
break;
default:
- while (list1 && list1 != list2) {
+ while (list1 && !equal(list1, list2)) {
ptail = list_collect(ptail, car(list1));
list1 = cdr(list1);
}
diff --git a/txr.1 b/txr.1
index 6ba20ac0..39fdf4f7 100644
--- a/txr.1
+++ b/txr.1
@@ -10310,8 +10310,8 @@ can also be treated in the same way.
The
.code ldiff
function is also extended in a special way. When the right parameter
-is a string or vector, then it uses the equal equality test rather than eq
-for detecting the tail of the list.
+a non-list sequence, then it uses the equal equality test rather than eq for
+detecting the tail of the list.
.cblk
(ldiff "abcd" "cd") -> (#\ea #\eb)
@@ -15710,7 +15710,7 @@ then a copy of
.meta list
is returned.
-These functions also work more generally on sequences.
+This function also works more generally on sequences.
The
.meta list
and