Bashed this out a few minutes ago. Time for bed.
I enjoy functional programming and cookies.
elm-snake - Snake game built using Elm
Elm is a functional reactive programming (FRP) language that compiles to HTML, CSS, and JS. FRP is a concise and elegant way to create highly interactive applications and avoid callbacks.
To play, download the
out/ folder and open
Just got basic map loading from JSON files - Like a boss.
At the moment only player-spawn, walls, and lighting are loaded from the map files. Cores, Fields, and power connections will shortly be added.
I’ve also forgotten to eat, so I’m having a pizza break!
The following are two simple procedures for ‘wrapped’ expressions:
(defn- wrapped? [_expression] " Detects if an expression is wrapped up in layers. 'y is not wrapped '(x) is wrapped on 'x '((((x + y)))) is wrapped on '(x + y) " (and (coll? _expression) (= 1 (count _expression)))) (defn- unwrap [_expression] " Iteratively unwraps an expression until it is no-longer wrapped. 'y --> 'y '((x)) --> 'x '(((((x * y))))) --> '(x * y) " (if (wrapped? _expression) (recur (first _expression)) _expression))
I authored these to help with my dissertation’s “tokenised infix expression” parser. They are used to eliminate singly-nested expressions.
Sub-expressions are now matched and swapped out if a reduction is made.
Conditionals evaluate with bindings correctly.
Executor forms also evaluate with bindings correctly.
I have a few abstract ideas about ensuring termination, but nothing properly explored yet.
As well as cycle capturing for termination, I also have to build an infix expression parser. For which, I am thinking about implementing a modified version of the shunting-yard algorithm. We’ll see how that goes.
I have a meeting with my project supervisor at 11am today. I’m wondering what he’ll say if I tell him I started from scratch two days ago and have already completed the core functionality. :D
Works in a completely different way and encompasses a wider range of actions.
Haven’t written the documentation yet though, but if anyone wants to try and understand it take a look at demo.html. It pretty much uses all aspects of the module.
Instead of operating on dom elements, it can now work on any data you pass it! If you want to modify collections of objects into a particular states, it allows for that. Custom element interpretation functions, custom property rules, etc…
Took about 4 or 5 hours to come up with the new ideas and to write.
After watching Chris Coyier (CSS-Tricks) give a screencast on the basics of Git and GitHub; I’ve finally joined and created my first repository!
It’s a tiny project I completed a few nights over the previous summer holidays.
Link to screencast: