15. May 2015

An interesting example of using a closure for memoization

Long ago I wrote about the benefits of memoization. It’s a simple idea: a time vs. space trade off. Trade time in CPU for space in memory. A pretty classic example is the massive speed benefit you can get while calculating the Fibonacci sequence by saving values you have already found. (The naive recursive approach recalculates values an exponential number of times.) It’s a toy example but it definitely exhibits the power of the technique.

more

03. May 2015

Playing with my espruino pico

About a year ago I had a little fun using an espruino. I recently “kick-started” their more recent product the espruino pico. This one did really well on kickstarter and I got some great “boost” rewards like an LCD screen and some relays. It should be fun to see what this thing can do.

more

18. April 2015

Finding Semordnilaps

My wife recently developed an interest in semordnilaps, so I thought I would take a stab at writing a script that will find some. What I came up with finds a subset of all two word to two word semordnilaps. Generally you don’t consider whitespace and punctuation in palindromes and semordnilaps, so this code doesn’t either.

more

10. April 2015

PHP’s traits vs. ruby’s modules: Battle of the mix-ins

A mixin is a class-like language construct meant to add functionality to another class. They are not meant to stand on their own, and generally speaking they cannot. Mixins can be used to give different classes the same interface. Mixins can be compared to multiple inheritence in what they let you accomplish, but they don’t work the same way. Rather than inheriting from multiple classes, you mix them in. (Hence the obvious name.)

more

14. February 2015

A Whitespace + Punctuation Tokenizer

In my previous post, I discussed some tokenization techniques and mentioned that a whitespace-only tokenizer will make tokens that are sub-optimal for indexing. I also mentioned that a simple solution to this is created a whitespace + punctuation tokenizer.

more