Fixing Random, part 18

added by DotNetKicks
4/3/2019 12:51:05 PM

1 Kicks, 457 Views

Before that silly diversion I mentioned that we will be needing the empty distribution; today, we'll implement it. It's quite straightforward: public sealed class Empty : IDiscreteDistribution { public static readonly Empty Distribution = new Empty (); private Empty() { } public T Sample() => throw new Exception("Cannot sample from empty distribution"); public IEnumerable Support() => Enumerable.Empty (); public int Weight(T t) => 0; } Easy peasy.


0 comments