mes: Add delete-duplicates.

* module/srfi/srfi-1.mes (delete-duplicates): New function.
This commit is contained in:
Jan Nieuwenhuizen 2018-04-29 18:32:35 +02:00
parent 75db8bed91
commit 4dfe6e00cc
No known key found for this signature in database
GPG key ID: F3C1A0D9C1D65273

View file

@ -100,4 +100,13 @@
(define last (compose car last-pair)) (define last (compose car last-pair))
(define (delete-duplicates lst . equal)
(let ((equal (and (pair? equal) (car equal))))
(let loop ((lst lst))
(if (null? lst) '()
(if (if equal (member (car lst) (cdr lst) equal)
(member (car lst) (cdr lst)))
(loop (cdr lst))
(cons (car lst) (loop (cdr lst))))))))
(include-from-path "srfi/srfi-1.scm") (include-from-path "srfi/srfi-1.scm")