# 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:** 15

<div class="post-metadata">

**Author:** ![Ian\_Slagle](https://avatars.discourse-cdn.com/v4/letter/i/b5a626/32.png) [@Ian\_Slagle](https://discourse.julialang.org/u/Ian_Slagle)\
**Post date:** [May 19, 2020, 3:56am UTC](https://discourse.julialang.org/t/opportunity-to-write-some-idiomatic-julia-code/39702/15 "2020-05-19T03:56:41Z")

</div>

And another version of the same length, but not using any packages

```julia
rand_geometric(x = 0) = rand(Bool) ? rand_geometric(x + 1) : x
P(m) = m <= 1 ? 0 : P(m - 1) + (1 - P(m - 1)) / 3 - (1 - P(m - 2)) * (2 / 9)
function O(x) 
    r, m = rand(1:x), rand_geometric()
    println(r == x ? (rand() <= P(m) ? "$(r + m) critical" : r + m) : 
        (r == 1 ? (rand() <= P(m) ? "$(r - m) fumble" : r - m) : r))
end

```

---

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