soyjeansoy
StreamData: how to generate a list of 2 strings with varied length
Hi!, how do i generate a list contains only 2 strings with varied length ie [“foo”, “baaar”]?
I tried:
# returns ["QrGgkWA7o1", "NbWbClnTYk"]
Enum.take(StreamData.string(:alphanumeric, length: 10), 2)
Marked As Solved
rodrigues
yeah @soyjeansoy it starts with the smallest strings and progresses into bigger lengths, not sure how “random” that can be.
iex(1)> StreamData.string(:alphanumeric) |> Enum.take(2)
["D", "k"]
iex(2)> StreamData.string(:alphanumeric) |> Enum.take(2)
["E", "yj"]
iex(3)> StreamData.string(:alphanumeric) |> Enum.take(20)
["j", "g", "yLc", "", "DxC8", "", "n", "q9kgIX", "", "Jg", "b", "jJs1",
"3UrpsF", "IcNUZBQ", "NC70Mt6Y4Daa", "s61D8798DT", "KiBfNzUonUT0Bg", "DVWUXgE",
"5J3s6GlISUrIGE", "SQLtS0KHTakmLhU"]
iex(4)> StreamData.string(:alphanumeric, max_length: 12) |> Enum.take(83)
["b", "LE", "", "", "H", "kMYa", "", "4hZuN", "jJ3dy", "0mGT9", "FURUUin",
"DzOI", "TTZhhaw6N9", "82vV", "nOYc1QH7", "4BWy", "OLeM4nH53Qw", "TDgXLM",
"tRl4ldXT", "vtu3H", "ZgRk", "", "o9xU", "S7wMlwblNv", "l3O0elqjVs1I",
"y2uedOct", "8esTi7", "dntRYmip", "ZADJRjfc4X", "AW", "Skpd8cO5YzI", "",
"OUxE", "QhFmCxkid", "", "XwofgD7aPVZ", "881", "xSgP5fmwnHbX", "Q6pF7jcLdx",
"L53yvQVqgcDQ", "H", "FMci4VTvM", "BsVp", "56", "eA2ZV", "", "llEjsPyurF",
"QFYnr", "uNIp", "kmbMS", ...]
You can pass a min_length if you don’t want them too small.
2
Popular in Questions
can someone please explain to me how Enum.reduce works with maps
New
I want to try my hand at web scraping. What tools/libraries do I need to use. I’m hoping to turn this into something professional so don’...
New
i’m a new one to elixir
which editor can i use
vs code? or atom?
Thanks! :smiley:
New
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
Could someone help me? I'm making my first elixir program, number guessing game. I can't figure out how to convert the user's guess from ...
New
Hi,
I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list....
New
Hi all,
I've just started learning Elixir and Phoenix Framework, so please pardon my n00bness at this stage.
I'm trying to use Postg...
New
I will often find my self writing things similar to:
case some_value do
nil -> something()
"" -> something()
_ -> someth...
New
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New
Expanding on this topic: https://forum.elixirforum.net/t/map-typespec-question/19217
Let’s say I have a map with required and optional k...
New
Other popular topics
Hi! May someone helps me, please!
I have two apps into an umbrella project: the first one is Database, which manages queries, and the se...
New
Phoenix 1.4.0 released
Phoenix 1.4 is out! This release ships with exciting new features, most notably
with HTTP2 support, improved deve...
New
TL;DR: I’ve just released an implementation of Microsoft’s IDE-independent Language Server Protocol for Elixir. It adds language support ...
New
Hi, this is for people who, like me, have had some friction using .html.heex templates in VSCode.
The solution seems to be, in a hyphena...
New
How to set Jason to encode all fields in ecto schema, I don’t care about security and implementing only is taking long list of attributes...
New
I’m working on defining a simple Ecto schema for a table (in PostGres), but I don’t see where I can define a column as NOT NULL. Conside...
New
Hi,
I'm quite new in Elixir and I'm trying to format a string to a PEM format. I have the certificate value like MIIDBTCCAe2...... and ...
New
Could someone help me? I'm making my first elixir program, number guessing game. I can't figure out how to convert the user's guess from ...
New
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
Why is it that the mnesia database isn’t the most preferred database for use in Elixir/Phoenix?
New







