ProductPromotion
Logo

Elixir

made by https://0x3d.site

GitHub - mrdimosthenis/minigen: Pure random data generation library, appropriate for realistic simulations in the Erlang ecosystem
Pure random data generation library, appropriate for realistic simulations in the Erlang ecosystem - mrdimosthenis/minigen
Visit Site

GitHub - mrdimosthenis/minigen: Pure random data generation library, appropriate for realistic simulations in the Erlang ecosystem

GitHub - mrdimosthenis/minigen: Pure random data generation library, appropriate for realistic simulations in the Erlang ecosystem

minigen

Pure random data generation library, appropriate for realistic simulations in the Erlang ecosystem.

Installation

  • For Erlang projects, add the dependency into rebar.config:
{deps, [
    {minigen, "0.1.1"}
]}.
  • For Elixir projects, add the dependency into mix.exs:
defp deps do
  [
    {:minigen, "~> 0.1.1", manager: :rebar3}
  ]
end
  • For Gleam projects, run gleam add minigen.

Usage

The examples below use the run function that will probably return different values on each call. If we want to get the same values on each call, we need to use run_with_seed instead.

Don't forget to visit https://hexdocs.pm/minigen/minigen.html to see the signature of the available functions: list, then, always, sequence, map, map2, map3, map4, map5. Their combination can generate values for any data type.

More examples can be found in the test directory of the GitHub repository.

Erlang examples

  • Create a random float number
GEN=minigen:float(),
minigen:run(GEN).
0.7938520785840248
  • Create a random integer number
GEN=minigen:integer(10),
minigen:run(GEN).
4
  • Create a random boolean value
GEN=minigen:boolean(),
minigen:run(GEN).
true
  • Get a random element from a list
GEN=minigen:element_of_list([1, 2, 3]),
minigen:run(GEN).
{ok,2}
GEN=minigen:element_of_list([]),
minigen:run(GEN).
{error,nil}
  • Shuffle a list
GEN=minigen:shuffled_list([1, 2, 3]),
minigen:run(GEN).
[2,1,3]
  • Create a random string
GEN=minigen:string(6),
minigen:run(GEN).
"3Rzpqd"

Elixir examples

  • Create a random float number
:minigen.float
|> :minigen.run
0.36087782004967894
  • Create a random integer number
:minigen.integer(10)
|> :minigen.run
8
  • Create a random boolean value
:minigen.boolean
|> :minigen.run
false
  • Get a random element from a list
:minigen.element_of_list(["a", "b", "c", "d"])
|> :minigen.run
{:ok, "c"}
:minigen.element_of_list([])
|> :minigen.run
{:error, nil}
  • Shuffle a list
:minigen.shuffled_list(["a", "b", "c", "d"])
|> :minigen.run
["c", "d", "b", "a"]
  • Create a random string
:minigen.string(7)
|> :minigen.run
"eJKp8sc"

Gleam examples

import minigen
  • Create a random float number
minigen.float()
|> minigen.run
0.16296012690374562
  • Create a random integer number
minigen.integer(10)
|> minigen.run
6
  • Create a random boolean value
minigen.boolean()
|> minigen.run
True
  • Get a random element from a list
minigen.element_of_list([0.5348931595479329, 0.47372875562526207, 0.7109364198110805])
|> minigen.run
Ok(0.7109364198110805)
minigen.element_of_list([])
|> minigen.run
Error(Nil)
  • Shuffle a list
minigen.shuffled_list([0.5348931595479329, 0.47372875562526207, 0.7109364198110805])
|> minigen.run
[0.47372875562526207, 0.5348931595479329, 0.7109364198110805]
  • Create a random string
minigen.string(8)
|> minigen.run
"U3j641WL"

Articles
to learn more about the elixir concepts.

Resources
which are currently available to browse on.

mail [email protected] to add your project or resources here 🔥.

FAQ's
to know more about the topic.

mail [email protected] to add your project or resources here 🔥.

Queries
or most google FAQ's about Elixir.

mail [email protected] to add more queries here 🔍.

More Sites
to check out once you're finished browsing here.

0x3d
https://www.0x3d.site/
0x3d is designed for aggregating information.
NodeJS
https://nodejs.0x3d.site/
NodeJS Online Directory
Cross Platform
https://cross-platform.0x3d.site/
Cross Platform Online Directory
Open Source
https://open-source.0x3d.site/
Open Source Online Directory
Analytics
https://analytics.0x3d.site/
Analytics Online Directory
JavaScript
https://javascript.0x3d.site/
JavaScript Online Directory
GoLang
https://golang.0x3d.site/
GoLang Online Directory
Python
https://python.0x3d.site/
Python Online Directory
Swift
https://swift.0x3d.site/
Swift Online Directory
Rust
https://rust.0x3d.site/
Rust Online Directory
Scala
https://scala.0x3d.site/
Scala Online Directory
Ruby
https://ruby.0x3d.site/
Ruby Online Directory
Clojure
https://clojure.0x3d.site/
Clojure Online Directory
Elixir
https://elixir.0x3d.site/
Elixir Online Directory
Elm
https://elm.0x3d.site/
Elm Online Directory
Lua
https://lua.0x3d.site/
Lua Online Directory
C Programming
https://c-programming.0x3d.site/
C Programming Online Directory
C++ Programming
https://cpp-programming.0x3d.site/
C++ Programming Online Directory
R Programming
https://r-programming.0x3d.site/
R Programming Online Directory
Perl
https://perl.0x3d.site/
Perl Online Directory
Java
https://java.0x3d.site/
Java Online Directory
Kotlin
https://kotlin.0x3d.site/
Kotlin Online Directory
PHP
https://php.0x3d.site/
PHP Online Directory
React JS
https://react.0x3d.site/
React JS Online Directory
Angular
https://angular.0x3d.site/
Angular JS Online Directory