FluentRandomPicker 1.0.0

Additional Details

Version 1 and 2 are no longer maintained. Please update to version 3...

There is a newer version of this package available.
See the version list below for details.
dotnet add package FluentRandomPicker --version 1.0.0                
NuGet\Install-Package FluentRandomPicker -Version 1.0.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="FluentRandomPicker" Version="1.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add FluentRandomPicker --version 1.0.0                
#r "nuget: FluentRandomPicker, 1.0.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install FluentRandomPicker as a Cake Addin
#addin nuget:?package=FluentRandomPicker&version=1.0.0

// Install FluentRandomPicker as a Cake Tool
#tool nuget:?package=FluentRandomPicker&version=1.0.0                

Fluent Random Picker

This library offers a nice, fluent way to pick random values. Probabilities can be specified, values can be weighted.

Examples

var randomNumber = Out.Of().Value(5).AndValue(6).PickOne();
// randomNumber is 5 or 6 with equal probability.
var randomChar = Out.Of()
                  .Value('a').WithPercentage(70)
                  .AndValue('b').WithPercentage(30)
                  .PickOne();
// randomChar is 'a' with a probability of 70 % and 'b' with a probability of 30 %.
var randomString = Out.Of()
                  .Value("hello").WithWeight(2)
                  .AndValue("world").WithWeight(3)
                  .PickOne();
// randomString is "hello" or "world", but the probability for "world" is 1.5 times as high.
var randomInts = Out.Of()
                  .Value(1).WithPercentage(80)
                  .AndValue(10).WithPercentage(10)
                  .AndValue(100).WithPercentage(5)
                  .AndValue(1000).WithPercentage(5)
                  .Pick(5);
// randomInts can be [1, 1, 1, 1, 1] with a higher probability or [1, 1, 100, 10, 1]
// or even [1000, 1000, 1000, 1000, 1000] with a very small probability.
var randomInts = Out.Of()
                  .Value(1).WithPercentage(70)
                  .AndValue(10).WithPercentage(15)
                  .AndValue(100).WithPercentage(10)
                  .AndValue(1000).WithPercentage(5)
                  .PickDistinct(2);
// randomInts can be [1, 10], [1, 100], [1, 1000] ... but not [1, 1], [10, 10], ...
var operation = Out.Of<Func<long, long>>()
                .Value(i => i + 2)
                .AndValue(i => i * 2)
                .AndValue(i => (long)Math.Pow(i, 2))
                .AndValue(i => (long)Math.Pow(i, i))
                .PickOne();

var result = operation(10);
// result equals 10 + 2 or 10 * 2 or 10^2 or 10^10. 
Product Compatible and additional computed target framework versions.
.NET net5.0 is compatible.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories (1)

Showing the top 1 popular GitHub repositories that depend on FluentRandomPicker:

Repository Stars
SapiensAnatis/Dawnshard
Server emulator for Dragalia Lost
Version Downloads Last updated
3.5.1 33,973 3/16/2024
3.5.0 13,277 11/11/2023
3.4.0 7,569 12/19/2022
3.3.0 1,009 7/2/2022
3.2.0 537 4/28/2022
3.1.0 4,389 11/27/2021
3.0.2 332 11/13/2021
3.0.1 382 8/7/2021
3.0.0 388 7/28/2021
2.1.0 494 7/10/2021 2.1.0 is deprecated.
2.0.1 363 6/28/2021 2.0.1 is deprecated.
2.0.0 462 6/26/2021 2.0.0 is deprecated.
1.2.0 484 5/22/2021 1.2.0 is deprecated.
1.1.1 357 5/15/2021 1.1.1 is deprecated.
1.1.0 375 4/24/2021 1.1.0 is deprecated.
1.0.4 349 4/17/2021 1.0.4 is deprecated.
1.0.3 350 4/16/2021 1.0.3 is deprecated.
1.0.2 391 4/15/2021 1.0.2 is deprecated.
1.0.1 344 4/15/2021 1.0.1 is deprecated.
1.0.0 382 4/15/2021 1.0.0 is deprecated.