summaryrefslogtreecommitdiffstats
path: root/lib.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2012-02-28 21:46:05 -0800
committerKaz Kylheku <kaz@kylheku.com>2012-02-28 21:46:05 -0800
commitc71cdf1461646ecaf56969d18bcc629039d7148d (patch)
tree0d340ab7ff9f621a71aa86a58f648e6010775374 /lib.c
parent8513e2e828aaefb9a5d0b7a5426ec433c2f69293 (diff)
downloadtxr-c71cdf1461646ecaf56969d18bcc629039d7148d.tar.gz
txr-c71cdf1461646ecaf56969d18bcc629039d7148d.tar.bz2
txr-c71cdf1461646ecaf56969d18bcc629039d7148d.zip
* debug.c: Missing d command implemented.
Condense the output to 8 times the screen width, for more context. Condense the output in vertical mode (when the entire input line is shown) not only character mode. * lib.c (remq, remql, remqual): New functions. * lib.h (remq, remql, remqual): Declared.
Diffstat (limited to 'lib.c')
-rw-r--r--lib.c45
1 files changed, 45 insertions, 0 deletions
diff --git a/lib.c b/lib.c
index 9aaa9f04..9f2b48ed 100644
--- a/lib.c
+++ b/lib.c
@@ -625,6 +625,51 @@ val memqual(val obj, val list)
return list;
}
+val remq(val obj, val list)
+{
+ list_collect_decl (out, ptail);
+ val lastmatch = cons(nil, list);
+
+ for (; list; list = cdr(list)) {
+ if (car(list) == obj) {
+ list_collect_nconc(ptail, ldiff(cdr(lastmatch), list));
+ lastmatch = list;
+ }
+ }
+ list_collect_nconc(ptail, cdr(lastmatch));
+ return out;
+}
+
+val remql(val obj, val list)
+{
+ list_collect_decl (out, ptail);
+ val lastmatch = cons(nil, list);
+
+ for (; list; list = cdr(list)) {
+ if (eql(car(list), obj)) {
+ list_collect_nconc(ptail, ldiff(cdr(lastmatch), list));
+ lastmatch = list;
+ }
+ }
+ list_collect_nconc(ptail, cdr(lastmatch));
+ return out;
+}
+
+val remqual(val obj, val list)
+{
+ list_collect_decl (out, ptail);
+ val lastmatch = cons(nil, list);
+
+ for (; list; list = cdr(list)) {
+ if (equal(car(list), obj)) {
+ list_collect_nconc(ptail, ldiff(cdr(lastmatch), list));
+ lastmatch = list;
+ }
+ }
+ list_collect_nconc(ptail, cdr(lastmatch));
+ return out;
+}
+
val tree_find(val obj, val tree, val testfun)
{
uses_or2;