Unique StreamData Result Generation

Tags: #<Tag:0x00007f8ea05bf7a8> #<Tag:0x00007f8ea05bf500> #<Tag:0x00007f8ea05bf230>


I am generating a list of atoms which looks like this,

[:c, :u, :d]
|> StreamData.one_of()
|> StreamData.list_of() 

A little more logic to it, but it generates this:

[[:c], [:c, :c, :u], [:c, :u, :u, :c], [:c], [:c, :d, :c], [:c, :c, :d],
 [:c, :d, :c, :u, :d, :c, :d], [:c, :d, :c, :u], [:c, :d, :c],
 [:c, :c, :u, :d, :d, :c, :u, :u, :u, :c, :d], [:c, :c, :c], …

Any way to ensure no dupes are generated?

Suspect the best way is with Enum?

E.g. [:c] is closely followed by [:c].

Not a big deal, just wondering, if it can be done in StreamData itself…


Maybe uniq_list_of/2 is what you are looking for? https://hexdocs.pm/stream_data/StreamData.html#uniq_list_of/2


I thought so also, but afaict, it ensures the elements of each individual list are unique, i.e. not

[:a, :a]

Rather than not

[[:a, :b], [:a, :b]]