Opportunity to write some idiomatic Julia code

Here is an abbreviated version of your code that merges the two loops:

function O6()
    s, t, crit = rand(1:6), 1, false
    s in (1,6) && while ((t′, t) = (t, rand(1:6)); t < 4)
       s += s ≥ 6 ? 1 : -1
       crit |= 1 == t′ == t
    end
    return s, crit ? (s > 6 ? :critical : :fumble) : nothing
end

which is shorter than the Forth code while being (I think) more readable.

7 Likes