TheSeamau5 / elm-checkerboardgrid-tutorial

Tutorial on Container Components in Elm
97 stars 9 forks source link

Do some rewriting of equivalent booleans #1

Closed evancz closed 9 years ago

evancz commented 9 years ago

Whenever your branches are bools, you can probably not have branches. If I am understanding things correctly, the shortest version is this:

(gridContext.row % 2 == 0) == (gridContext.column % 2 == 0)

Meaning they are both even or they are both odd.

TheSeamau5 commented 9 years ago

Thanks! I've made the changes in 16d66e4cc5fd9b2fcf4278bc7a8add15166b8e1c

evancz commented 9 years ago

Cool :) Nice, post by the way!

TheSeamau5 commented 9 years ago

Thanks. I felt like after a while I just figured out how to get a container component to communicate with the child component and have that child component do stuff based on that data while neither knows that the other exists. In retrospect it sounds obvious that the best way to compose stuff is via function composition, but I assure you, it wasn't obvious at all at first.