Skip to main content
11 events
when toggle format what by license comment
Mar 9, 2015 at 7:08 history edited tokland CC BY-SA 3.0
added 6 characters in body
Dec 27, 2014 at 9:59 comment added tokland There is plenty of material on FP. Regarding FP+Ruby, I have this: slideshare.net/tokland/functional-programming-with-ruby-9975242
Dec 26, 2014 at 23:11 comment added Cary Swoveland I wasn't aware that functional programming eschews in-place updates. I really need to read up on that, at least to acquaint myself with the arguments for adopting that approach to coding.
Dec 26, 2014 at 19:07 comment added tokland @Cary: It would be a bit easier to read indeed, but a functional approach forbids in-place updates. Here it's not a big deal, but with more complex algorithms having no updates makes thing easier to follow.
Dec 24, 2014 at 16:08 comment added Cary Swoveland I like your solution, but I think state[:going_east] += 1 and state[:passing] += state[:going_east] reads better than the somewhat forced merges. I realize you used merge to avoid the need for a pesky state at the end of the reduce block, but you can deal with that by using each_with_object rather than reduce.
Dec 21, 2014 at 22:07 comment added Mohamad I don't think it looks complicated. It does look different, though. Usually, I find functional code a bit harder to read. That's a psychological barrier, I think. I asked how long it took you because I want to compare: It takes me a lot longer, maybe 10 to 20 minutes to write a solution to this problem, and there's no guarantee it will be as succinct and well written as yours. I'm just trying to gage my ability, I suppose, and when you tell me a couple of minutes, it doesn't bode well for me :D
Dec 21, 2014 at 21:05 comment added tokland I don't know, a couple of minutes? does it look complicated? it's pretty standard stuff (a simple Finite-State-Maching), in FP style you do a folding (reduce/inject) with the initial state over the collection to process.
Dec 21, 2014 at 20:22 comment added Mohamad I'm curious, how long did it take you to write this solution?
Dec 21, 2014 at 16:37 history undeleted tokland
Dec 21, 2014 at 16:36 history deleted tokland via Vote
Dec 21, 2014 at 16:34 history answered tokland CC BY-SA 3.0