Unique StreamData Result Generation

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

1 Like

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]]

1 Like

Nothing prevents you from making a generator that produces one such atom list and then compose it through uniq_list_of on a higher level. Unless I misunderstood you.