tag:blogger.com,1999:blog-5359546512544809971.post834386551988645814..comments2018-01-11T10:08:20.217-08:00Comments on Jeremy Bytes: Approaching Functional Programming Completely WrongJeremyhttp://www.blogger.com/profile/06749690234470413216noreply@blogger.comBlogger7125tag:blogger.com,1999:blog-5359546512544809971.post-25953506680566507802017-03-19T11:41:08.450-07:002017-03-19T11:41:08.450-07:00A completely worthwhile video on the functional de...A completely worthwhile video on the functional design of a board game (possible) vs OOD (nigh impossible)<br />https://m.youtube.com/watch?v=Tb823aqgX_0<br /><br />How OOP may be relevant<br />https://www.quora.com/What-differentiates-a-programmer-and-a-really-good-programmer-How-are-the-codes-being-considered-as-good-or-bad/answer/Christian-BauneS AHMED MUHAMMADhttps://www.blogger.com/profile/17947179762917109401noreply@blogger.comtag:blogger.com,1999:blog-5359546512544809971.post-57872866187807095932017-03-18T13:40:30.993-07:002017-03-18T13:40:30.993-07:00The westward runs in the sidewinder maze make grow...The westward runs in the sidewinder maze make growing a tree in that case rather more complicated. That was a fun problem to solve given the constraints of immutability and being able to draw appropriate arrows from "<V>" in each cell as appropriate, based on a linked tree structure. There's a gist for that too.Steve Gilhamhttps://www.blogger.com/profile/03622573187942388226noreply@blogger.comtag:blogger.com,1999:blog-5359546512544809971.post-65987442284446972432017-03-18T09:36:00.702-07:002017-03-18T09:36:00.702-07:00You're welcome. Puzzles like this are fun.
I...You're welcome. Puzzles like this are fun.<br /><br />It's comparatively simple to augment the previous example so that each cell knows whether it can be entered from the south or the west (and draw " ", "< ", " V " or "<V " in each cell as appropriate) locally by brute force, and with a little more thought, it turns out to be simpler to do so by taking advantage of the "grain" of the algorithm and growing a tree structure incrementally from the SW corner that ends up rooted in the NE cell (https://gist.github.com/SteveGilham/299e0561c2ac0586fc35485e81989be6). I'm pretty certain that direct linking in the opposite direction as well can't be done immutably, but a separate immutable data-structure can be built to map cells to their exits (extend the Connected type with a self-coordinate pair initialised by accumulation, build a pair to node map, then for each node compute exit coordinate and build a node to exit node map), which then between them allow us to traverse arbitrary paths.Steve Gilhamhttps://www.blogger.com/profile/03622573187942388226noreply@blogger.comtag:blogger.com,1999:blog-5359546512544809971.post-17227860913798052102017-03-16T20:32:45.484-07:002017-03-16T20:32:45.484-07:00Thanks, James. You're right; this is probably ...Thanks, James. You're right; this is probably a bit deep for me at the moment, but it may be useful once I dig in a bit more. I appreciate the help.Jeremyhttps://www.blogger.com/profile/06749690234470413216noreply@blogger.comtag:blogger.com,1999:blog-5359546512544809971.post-54933471028870028762017-03-16T20:28:26.354-07:002017-03-16T20:28:26.354-07:00Thanks, Steve. I appreciate the example. This will...Thanks, Steve. I appreciate the example. This will be great for me to dig through and help me think about the problem differently.Jeremyhttps://www.blogger.com/profile/06749690234470413216noreply@blogger.comtag:blogger.com,1999:blog-5359546512544809971.post-28238049119708297592017-03-16T16:25:52.705-07:002017-03-16T16:25:52.705-07:00I feel like I'd be helping if I pointed you in...I feel like I'd be helping if I pointed you in the direction of the ‘fgl’ library for Haskell as an example of how to work with graphs in a functional way, and comonads (especially the ‘store’ comonad) for the case where you have a ‘position’ and want to do things with your local ‘environment’.<br />That's kind of a deep end to jump into, though, so maybe it would hinder more than help to try that at this point. Who knows.James Kayhttps://www.blogger.com/profile/07116187714551272040noreply@blogger.comtag:blogger.com,1999:blog-5359546512544809971.post-60135357254591829302017-03-16T10:22:49.773-07:002017-03-16T10:22:49.773-07:00To just draw a maze using that generation algorith...To just draw a maze using that generation algorithm, my first jottings are here -- https://gist.github.com/SteveGilham/ca75810bb7b588905c80e4d1dfc26931<br /><br />It includes the special cases of the top row (no northern neighbours) and right-hand column (no eastern neighbours) somewhat more explicitly than the OO/imperative starting point does.Steve Gilhamhttps://www.blogger.com/profile/03622573187942388226noreply@blogger.com