This is the mail archive of the guile@sources.redhat.com mailing list for the Guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

(ice-9 common-list) `uniq' replacement


this version of `uniq' doesn't overflow the default guile stack like the
one in (ice-9 common-list) does for very large inputs.  the `reverse' is
habitual, feel free to omit it...

thi

________________________________
(define (ttn-uniq l)
  (let loop ((acc '())
             (l l))
    (if (eq? '() l)
        (reverse acc)
        (loop (if (memq (car l) acc)
                  acc
                  (cons (car l) acc))
              (cdr l)))))

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]