concept comma in category elixir

appears as: commas, comma
The Little Elixir & OTP Guidebook

This is an excerpt from Manning's book The Little Elixir & OTP Guidebook.

There’s a tiny problem, though. What’s the probability that QuickCheck generates a string that contains commas? Let’s find out with collect/2:

Nice! How do you include commas as part of the generated string? A naïve way would be to add the comma character as part of the generated string:

vector(len, oneof(:lists.seq(?a, ?z) ++ [?,]))

The problem with this approach is that you can’t control how many times the comma appears. You can fix this using frequency/1. It’s easier to show how frequency/1 is used before explaining: