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...
For further actions, you may consider blocking this person and/or reporting abuse
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.'
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 andxor
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 :)You've got a typo in your second code block. "divisibleBy4" is used all three times.
Nice catch - thank you.
Nice! It's great to see the process of solving an exercism.io exercise. Keep doing this! What your thoughts about Clojure and ClojureScript?
That XOR operator, dammmnnn! :O
Aside from exercism.io, Where else are you learning elm from?
Pragmatic Studio has a great course: pragmaticstudio.com/elm
Awesome post! Really shows how great Elm is for iterating/refatoring!
Doesn't xor break for years divisible by 400?
xor true (true or true) -> xor true true -> false
Or am I reading this wrong
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 gettrue
for years divisible by 400.Is the link to exercism.io broken?