GNU bug report logs -
#26540
25.2; [PATCH] Add cl-set-equal to test for set equality
Previous Next
Reported by: Damien Cassou <damien <at> cassou.me>
Date: Mon, 17 Apr 2017 09:17:01 UTC
Severity: wishlist
Tags: patch
Found in version 25.2
Done: Nicolas Petton <nicolas <at> petton.fr>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
Hi Michael,
Michael Heerdegen <michael_heerdegen <at> web.de> writes:
> Damien Cassou <damien <at> cassou.me> writes:
>> it makes sense and I will try this way. Nevertheless, it also
>> means giving up on the :key feature. I guess it's ok.
>
> OTOH I see no reason not to support it. There is no reason to
> provide a function in a library specializing on sequences with
> less features than in some other lib.
I agree with you that having :key would be nice. Nevertheless, my
implementation currently relies on functions of seq.el (i.e.,
seq-contains) which would have to be adapted to support :key. I
didn't want to do that.
> [...] with this implementation using hash-tables:
>[]
> #+begin_src emacs-lisp (defun seq-set-equal-2 (sequence1
> sequence2)
> (let ((table1 (make-hash-table :size (length sequence1)))
> (table2 (make-hash-table :size (length sequence2))))
> (seq-doseq (elt sequence1) (puthash elt t table1))
> (seq-doseq (elt sequence2) (puthash elt t table2)) (and
> (seq-every-p (lambda (elt) (gethash elt table2)) sequence1)
> (seq-every-p (lambda (elt) (gethash elt table1))
> sequence2))))
> #+end_src
as far as I can tell, little effort has been put in optimizing
seq.el the way you describe it so I guess such an implementation
of seq-set-equal would feel a bit alien in the current code
base. Moreover, is your implementation faster on very small sets?
Finally, making your implementation of seq-set-equal accepting a
TESTFN parameter would be a bit complex as you would have to pass
that to `make-hash-table` which also requires a hash function.
--
Damien Cassou
http://damiencassou.seasidehosting.st
"Success is the ability to go from one failure to another without
losing enthusiasm." --Winston Churchill
This bug report was last modified 8 years and 13 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.