Feedback for newbie - please review my code

Hi! I’m new to both elixir and this forum, so if i’m doing stuff wrong please tell me, and i’ll correct it :slight_smile:

I’ve written a library to rate poker hands as my first real project in elixir, comming from a php and javascript background. It’s working, but considering I’m a newbie, i guess there’s some stinky and straight out bad code in there :stuck_out_tongue:

If someone would care to take a glance at it, and maybe hint at some improvements that could be made, i would be very grateful!

I’ve made a repo here:

Thanks for your time!


I’ve just had a quick glance. Looks quite good overall. I noticed two things:

  • Instead of repeated calls to elem/2 just pattern match the actual values in the function head
  • I doubt you really need to use the Stream module especially as you use Stream.take(5) immediately. Unless you need streams for lack of enough memory or other reasons it’s usually best to stick to Enum.


Thanks for your time!

  1. Ah! That will clean it up a bunch, thanks!
  2. Alright. I thought I could save some unnecessary looping by doing stream instead of enum. But it might be overkill and hurt readability in this case… I could then also import all the enum methods i use at the top of the file, to clean it up further.

Really appreciate your feedback :slight_smile:

Edit. I’ve updated the repo to implement your suggestions, I do think it reads better now :slight_smile:

I don’t really know enough about Elixir to critique your code but I just wanted to commend you on writing such consistent docs.