DEV Community

"Elm Has Me Leaping For Joy"

Vince Campanale on August 28, 2017

I'm very new to Elm (a couple of weeks) and am working through exercises on exercism.io. I see a lot of potential in this language and am enjoyin...
Collapse
 
yossarian profile image
Yossarian

Nice article. Not sure about the refactoring though. With rem and xor additions readability decreased. Not sure why it make it better, especially with the former?

As Martin Fowler once said 'Good programmers write code that humans can understand.'

Collapse
 
vincecampanale profile image
Vince Campanale

I actually find the refactor more readable, but one man's variable is another man's constant I guess. To me, rem looks like remainder and xor is reminiscent of "except". The former is simpler and more traditional, but less semantic. At the end of the day though, it's a very simple exercise so I would have felt like I missed an opportunity to improve if I just solved it quick and moved on :)

Collapse
 
stephenjbell_81 profile image
Stephen Bell

You've got a typo in your second code block. "divisibleBy4" is used all three times.

Collapse
 
vincecampanale profile image
Vince Campanale

Nice catch - thank you.

Collapse
 
brunoti profile image
Bruno Oliveira

Nice! It's great to see the process of solving an exercism.io exercise. Keep doing this! What your thoughts about Clojure and ClojureScript?

Collapse
 
putopavel profile image
Pavel Razgovorov

That XOR operator, dammmnnn! :O

Collapse
 
maestromac profile image
Mac Siri

Aside from exercism.io, Where else are you learning elm from?

Collapse
 
vincecampanale profile image
Vince Campanale

Pragmatic Studio has a great course: pragmaticstudio.com/elm

Collapse
 
ruiclarateixeira profile image
Rui Teixeira

Awesome post! Really shows how great Elm is for iterating/refatoring!

Collapse
 
hurstc profile image
Chris H • Edited

Doesn't xor break for years divisible by 400?

xor true (true or true) -> xor true true -> false

Or am I reading this wrong

Collapse
 
vincecampanale profile image
Vince Campanale • Edited

You're correct. That's why the second half of the expression has || divisiblyBy 400 year. For a number divisible by 400, the first half evaluates to false, then the second half evaluates to true, false || true -> true, so we get true for years divisible by 400.

Collapse
 
maxdevjs profile image
maxdevjs

Is the link to exercism.io broken?