Numbers

version 1 by Krister Fundin

  • Home page
  • Beginning
  • Previous



  • Part 4 - Miscellaneous

    To decide which K is a random (name of kind of arithmetic value K) between (low - K) and (high - K) excluding (ex - K):
        (- RandomExclude(R_{-printing-routine:K}, {low}, {high}, {ex}) -).

    To decide which K is a random (name of kind of arithmetic value K) from (low - K) to (high - K) excluding (ex - K):
        (- RandomExclude(R_{-printing-routine:K}, {low}, {high}, {ex}) -).

    Include
    (-
        [ RandomExclude rule low high ex val;
            if (ex < low || ex > high)
            {
                return rule(low, high);
            }
            else
            {
                val = rule(low, high - 1);
                if (val >= ex) ++val;
                return val;
            }
        ];
    -).

    Numbers ends here.