mmport80

mmport80

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

Most Liked

sneako

sneako

Maybe uniq_list_of/2 is what you are looking for? StreamData — StreamData v1.3.0

mmport80

mmport80

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

Last Post!

dimitarvp

dimitarvp

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.

Where Next?

Popular in Questions Top

minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
lastday4you
I wanted to check elixir version in phoenix because i found that my elixir is 1.5 but when i use Enum.chunk_by it said the function is un...
New
lanycrost
Hi everyone! I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New
stefanchrobot
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
dokuzbir
I want to highlight html closing tags when i click a html tag. That works in .html files but doesnt work for html.eex templates. How can...
New
jerry
Good day to you all. I have been struggling to get a query involving like and ilike to work. Can anyone assist me on this, please? pro...
New
SoCreat
i’m a new one to elixir which editor can i use vs code? or atom? Thanks! :smiley:
New

Other popular topics Top

nobody
Hi! In PHP: $_SERVER[‘SERVER_ADDR’] - in Elixir? Searched the docs for ip address and the web, no good results. Thanks!
New
jononomo
I am trying to figure out how Mix knows whether the environment is test, dev, or prod – where is this set? Thanks.
New
JakeBecker
TL;DR: I’ve just released an implementation of Microsoft’s IDE-independent Language Server Protocol for Elixir. It adds language support ...
1144 54996 245
New
aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
New
greenz1
I have a phoenix application from which a user can download multiple(5-6) files of size 1MB. I couldn’t find anything related to sending ...
New
msaraiva
Surface is an experimental library built on top of Phoenix LiveView and its new LiveComponent API that aims to provide a more declarative...
564 44167 214
New

We're in Beta

About us Mission Statement