Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Code used Rust, interesting, I have come to expect Python and just recently used the open source version of Matlab called Octave.


Author here. I thought no one was going to make comments about Rust, but I just loved using it for this post.

Thanks, Peter :)


Rust is cool and all but I feel like the code examples would have been a bit more didactic in e.g. Julia since there's less distracting complexity in those types of languages. Here's a somewhat equivalent translation of the first snippet:

  rolls = 1_000_000
  n_sides = 6
  sevens = 0
  
  for _ in 1:rolls
      if rand(1:n_sides) + rand(1:n_sides) == 7
          sevens += 1
      end
  end
  println(sevens/rolls * 100)


I have been looking for an excuse to use Rust, thank you for the interesting post on all counts...




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: