1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-24 20:30:28 +02:00

* common-list.scm (uniq): Made tail-recursive. Thanks to thi!

This commit is contained in:
Marius Vollmer 2000-07-23 23:12:02 +00:00
parent e85da7d990
commit 23d919087e

View file

@ -225,10 +225,11 @@ non-#f return values of P."
(define-public (uniq l) (define-public (uniq l)
"Return a list containing elements of L, with duplicates removed." "Return a list containing elements of L, with duplicates removed."
(let loop ((acc '())
(l l))
(if (null? l) (if (null? l)
'() (reverse! acc)
(let ((u (uniq (cdr l)))) (loop (if (memq (car l) acc)
(if (memq (car l) u) acc
u (cons (car l) acc))
(cons (car l) u))))) (cdr l)))))