HCoop
/
bpt
/
guile.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
e85da7d
)
* common-list.scm (uniq): Made tail-recursive. Thanks to thi!
author
Marius Vollmer
<mvo@zagadka.de>
Sun, 23 Jul 2000 23:12:02 +0000
(23:12 +0000)
committer
Marius Vollmer
<mvo@zagadka.de>
Sun, 23 Jul 2000 23:12:02 +0000
(23:12 +0000)
ice-9/common-list.scm
patch
|
blob
|
blame
|
history
diff --git
a/ice-9/common-list.scm
b/ice-9/common-list.scm
index
02d1858
..
ebb13fe
100644
(file)
--- a/
ice-9/common-list.scm
+++ b/
ice-9/common-list.scm
@@
-225,10
+225,11
@@
non-#f return values of P."
(define-public (uniq l)
"Return a list containing elements of L, with duplicates removed."
- (if (null? l)
- '()
- (let ((u (uniq (cdr l))))
- (if (memq (car l) u)
- u
- (cons (car l) u)))))
-
+ (let loop ((acc '())
+ (l l))
+ (if (null? l)
+ (reverse! acc)
+ (loop (if (memq (car l) acc)
+ acc
+ (cons (car l) acc))
+ (cdr l)))))