diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2012-02-28 21:46:05 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2012-02-28 21:46:05 -0800 |
commit | c71cdf1461646ecaf56969d18bcc629039d7148d (patch) | |
tree | 0d340ab7ff9f621a71aa86a58f648e6010775374 /lib.c | |
parent | 8513e2e828aaefb9a5d0b7a5426ec433c2f69293 (diff) | |
download | txr-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.c | 45 |
1 files changed, 45 insertions, 0 deletions
@@ -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; |