(lset-adjoin): Revert change using `list' not `acc', the
authorKevin Ryde <user42@zip.com.au>
Thu, 17 Feb 2005 20:35:11 +0000 (20:35 +0000)
committerKevin Ryde <user42@zip.com.au>
Thu, 17 Feb 2005 20:35:11 +0000 (20:35 +0000)
spec is not quite clear, but reference code uses acc, so do that.

srfi/srfi-1.scm

index 8d8a21d..21cad74 100644 (file)
               (every (lambda (el) (member el f (lambda (x y) (= y x)))) (car r))
               (lp (car r) (cdr r)))))))
 
+;; It's not quite clear if duplicates among the `rest' elements are meant to
+;; be cast out.  The spec says `=' is called as (= lstelem restelem),
+;; suggesting perhaps not, but the reference implementation shows the "list"
+;; at each stage as including those elements already added.  The latter
+;; corresponds to what's described for lset-union, so that's what's done.
+;;
 (define (lset-adjoin = list . rest)
   (let lp ((l rest) (acc list))
     (if (null? l)
       acc
-      (if (member (car l) list (lambda (x y) (= y x)))
+      (if (member (car l) acc (lambda (x y) (= y x)))
        (lp (cdr l) acc)
        (lp (cdr l) (cons (car l) acc))))))