# Opportunity to write some idiomatic Julia code

**URL:** <https://discourse.julialang.org/t/opportunity-to-write-some-idiomatic-julia-code/39702>\
**Category:** Community\
**Created:** [May 18, 2020, 4:14pm UTC](https://discourse.julialang.org/t/opportunity-to-write-some-idiomatic-julia-code/39702 "2020-05-18T16:14:23Z")\
**Posts on this page:** 1\
**Showing post:** 9

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [May 18, 2020, 8:36pm UTC](https://discourse.julialang.org/t/opportunity-to-write-some-idiomatic-julia-code/39702/9 "2020-05-18T20:36:32Z")

</div>

> [@tkluck](#):
>
> An entry for fewest lines:

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

```julia
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](https://github.com/isene/O6/blob/master/O6-forth.fs) while being (I think) more readable.

---

_[View the full topic](https://discourse.julialang.org/t/opportunity-to-write-some-idiomatic-julia-code/39702)._
