Exemplo n.º 1
0
        /// <summary>
        /// Creates a uniform distribution over all digits from 0 to <paramref name="maxDigit"/> (inclusive),
        /// excluding <paramref name="digit"/>.
        /// </summary>
        /// <param name="digit">The digit to exclude.</param>
        /// <param name="maxDigit">The maximum digit.</param>
        /// <returns>The created distribution.</returns>
        private static DiscreteChar AllDigitsExcept(int digit, int maxDigit)
        {
            Debug.Assert(maxDigit >= 0 && maxDigit <= 9 && digit >= 0 && digit <= 9, "The parameters must represent digits.");
            Debug.Assert(digit <= maxDigit, "digit must be between 0 and maxDigit.");
            Debug.Assert(maxDigit > 0, "The distribution must cover at least one digit.");

            if (digit == 0)
            {
                return(DiscreteChar.InRange('1', (char)('0' + maxDigit)));
            }

            if (digit == maxDigit)
            {
                return(DiscreteChar.InRange('0', (char)('0' + maxDigit - 1)));
            }

            return(DiscreteChar.InRanges('0', (char)('0' + digit - 1), (char)('0' + digit + 1), (char)('0' + maxDigit)));
        }
Exemplo n.º 2
0
 private static StringDistribution WordString() => StringDistribution.OneOrMore(DiscreteChar.InRanges("azAZ09  __''\t\r"));