# Remove redundant brackets from expressions with Falafel

I am writing a static analyser for Firebase. My approach to precedence and brackets has always been, if in doubt, whack a bracket round it. Unfortunately when writing code generation tools my output ends up with more brackets than logic :s

Anyway, I was having trouble debugging my generated code, and it was impossible to reason why it wasn’t working what with all the brackets. So I kept with maximum bracket insertion in the 1st pass (a reliable strategy), but wrote a function for removing ALL redundant brackets from a Javascript expression post 1st pass (easier to read). It took a while to get right but I was very pleased with the brevity.

So the expression: (4 + 6) * 6 needs its brackets to operated correctly, but (((4) + (7) * 8) has a number of pointless brackets in it. There are some tricky cases like 5 / (7 * 6), which requires brackets despite * and / having equal precedence. To understand why 5 / (6 * 7) needs brackets you have to understand that when operators have equal precedence, by default, they associate to the left. Anyway the code to actually do this turned out to be super compact so I share it with you!

I used node-falafel which is an awesome package that allows in place source code rewrites during a bottom up parse. Woah! The function “simplify” takes an expression as a string, and returns a functionally equivalent expression but without the pointless brackets in it. Nice!

# Weaving Wolfram Rule 90

I’ve been interested for a while in cellular automata, pattern generating mathematical formulae such as Rule 90

There are many of these rules, each generating different behaviour. Each rule generates the content of cells in a column based on the cells in the preceding column, and are each based upon given starting conditions.

These are the rules for Rule 90:

 current pattern 111 110 101 100 011 010 001 000 new state for center cell 0 1 0 1 1 0 1 0

# Make a game month results!

Ahhh, #makgammon, make-a-game-month, is over. I have semi-recovered from the development exhaustion. The single transferable votes have been counted. I have the results!

Before that I would like to say #makgammon was really amazing this year. We had 6 entries, all of which represented a significant contribution in different ways. The spread of games was broad, so there was something for everyone. This was represented in the votes! We asked people to order the games by personal preference (of the games they played). Those orderings were pretty random, indicating that at least someone really liked *every* game. So it just goes to show, you can’t please everyone (so you should never try)! If a game dev did not win a prize, don’t feel bad, because someone in our judging audience did like the concept.

That said, the games that did win did appear higher on average in most people’s score sheet. So congrats to those for winning the mainstream appeal awards. Our prizes were kindly donated by Scirra who make the game development software “Construct 2”. I used that software to build Universal Machine, and I was blown away by how productive I was in 4 weeks. I think its fair to say that even if Universal Machine did not “win”, it was the most complex game, indicating how useful Construct 2 is as a productivity tool. So without further “ado”, the results…
[…]

# Mini Maker Faire 2014 is coming!

Good news everyone! After the success of the first Mini Maker Faire in Edinburgh last year, it’s coming back in 2014! MMF 2014 will be held at Summerhall and promises to be bigger and better than last year. The call for makers is open now. If you make cool things and have some interesting things Read more about Mini Maker Faire 2014 is coming![…]

# Arduino Workshop – Saturday 23rd November

Arduino is a micro-controller platform designed for ease of use and learning. It allows the creation of electronically controlled projects, whether it be simple blinking lights, a robot or a music generator. This workshop is aimed at beginners. You don’t needs any previous electronics or programming knowledge or experience. Topics covered include: An introduction to Read more about Arduino Workshop – Saturday 23rd November[…]

# Make a game month

Come join us Edinburgh for the second make-a-game-in-a-month, month. Stretch yourself creatively or technically to create something fun. Demo day is Sat. Nov 30th and open to the public, you can come to play other peoples games even if you’re not authoring. Tell your friends!

# Edinburgh Hacklab is three! Come and party!

In Summer 2010, 12 hackers/makers got together and rented a studio at Out of the Blue so that they could have somewhere to work, to keep equipment and to share with the rest of the community (apparently, having a milling machine on a coffee table in your lounge is okay for a bit but doesn’t Read more about Edinburgh Hacklab is three! Come and party![…]

# Probabalistic Scraping of Plain Text Tables

Recently I have been banging my head trying to import a ton of OCR acquired data expressed in tabular form. I think I have come up with a neat approach using probabilistic reasoning combined with mixed integer programming. The method is pretty robust to all sorts of real world issues. In particular, the method leverages Read more about Probabalistic Scraping of Plain Text Tables[…]

# Arduino Workshop – 31st August 2013

Arduino is a micro-controller platform designed for ease of use and learning. It allows the creation of electronically controlled projects, whether it be simple blinking lights, a robot or a music generator. This workshop is aimed at beginners. You don’t needs any previous electronics or programming knowledge or experience. Topics covered include: An introduction to Read more about Arduino Workshop – 31st August 2013[…]