Stream: Elpi users & devs

Topic: Set merge does not remove duplicates

view this post on Zulip Enzo Crance (Mar 04 2021 at 16:25):

Hello. I need to generate values and collect them recursively without keeping duplicated values. I have tried using elpi's implementation of sets. The sets from recursive calls to my predicate are merged into the output set. However, using the std.set.private.merge predicate for the merger does not actually remove the duplicates. Could it come from the fact that it is a set of terms I am generating, and that I am using cmp_term to build the sets? Thanks for the help!

view this post on Zulip Enrico Tassi (Mar 04 2021 at 16:32):

I'm a bit confused, you should not call std.set.private.merge since it is private. The set library misses the union API, which is embarassing... you can either fold add or implement it adapting the ocaml code as I did for the rest of the set library, see (as you can see merge is not union, but rather an internal auxiliary function)

view this post on Zulip Enzo Crance (Mar 04 2021 at 16:35):

I see. I think I'll go with the first solution, a.k.a. using the public API only and folding add for now. Thank you!

Last updated: May 18 2024 at 10:02 UTC