[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: seq-union calling seq-reverse? (Emacs master 0cf0a2b98671: Add new s
From: |
Stefan Kangas |
Subject: |
Re: seq-union calling seq-reverse? (Emacs master 0cf0a2b98671: Add new sequence function 'seq-union') |
Date: |
Fri, 17 Sep 2021 05:18:39 -0700 |
Štěpán Němec <stepnem@gmail.com> writes:
> +(cl-defgeneric seq-union (sequence1 sequence2 &optional testfn)
> + "Return a list of all elements that appear in either SEQUENCE1 or
> SEQUENCE2.
> +Equality is defined by TESTFN if non-nil or by `equal' if nil."
> + (let ((accum (lambda (acc elt)
> + (if (seq-contains-p acc elt testfn)
> + acc
> + (cons elt acc)))))
> + (seq-reverse
> + (seq-reduce accum sequence2
> + (seq-reduce accum sequence1 '())))))
> +
>
> `seq-reverse' seems gratuitous here WRT the purpose of `seq-union'.
I have pushed a fix to make it use `nreverse' instead. This is faster,
and in line with e.g. seq-partition, seq-uniq, etc.