Here’s some code to find greatest common divisors in Knuth’s MMIX. It’s faster than published implementations I know of and does not use predicated instructions like conditional stores.
I use Emacs together with Evil mode, a combo I settled on after many years in part because of its extensibility. Not long after I started using Evil mode, I wanted Vim text objects representing C++ functions. This turned out to be a good exercise in learning about Evil mode. It also shows off the things Emacs can help you do with just a little study.
Recently I needed a way to check whether a callable C++ thing (like a lambda)
could be applied to a given list of potential arguments. More precisely, I
wanted to know, given a lambda
f and list of arguments
a1, a2, ..., an,
whether the expression
f(a1, a2, ..., an) would compile. I came up with a way
to do it that I’m pleased with. Here’s an example of the interface:
Pony is a relatively new actor based programming language. It’s inspired by Erlang, but differs in some important (and cool) ways. I wanted to learn about Pony’s message passing model, so I decided to write up a solution to the dining philosophers problem. Here’s what I found. The code is available on github if you’re interested in that.
Resource “ownership” in software is tricky. Poorly thought out ownership can lead to issues with memory management, lifetime management, and other problems that make you want to bang your head on the desk. In a language like C or C++, you were traditionally on our own, responsible for keeping track of ownership and lifetimes without help from the compiler or language itself. But these days, things are changing for the better.
I wanted a link checker for my site my new static site, and I couldn’t find
one that used metalsmith or gulp. The closest thing I found was some code on
but even it had some problems. So, using that answer as a template, I wrote
my own very simple but functional link checker. But is it even worth adding
Gulp to the toolbelt? Spoiler: no. Gulp is crap,
make does everything I need
and more, and is easier and better. I stopped using Gulp.
This post my self-flagellation for spending quite a bit of time tracking down a problem with some code I was writing. The error was tricky, but I should have known better, and afterward I made the connection with some other tricky bits I knew about in different languages. Let’s look at the problem, which involves environments and closures (and probably other stuff, too!)
The C++ standard says that
vector::push_back should run in amortized
constant time. With a simple implementation where the vector is stored as an
array which doubles in size when needed and each element is copied on every
doubling, does this satisfy the time complexity requirement?
I have lots of heros and role models: mathematicians, compter scientists, academics, practicioners, articulate polymaths, and even a politician or two. Here I’ve collected some quotes I like. I’ll periodicaly add to them if I can remember to.
One problem I have faced a couple of times in the past is this: we’re given a list of objects, and a list of identifications of two objects. How many groups of objects are there after we perform the identifications? In mathematical parlance we’re given a set, a relation, and we’re asked to find the equivalence classes under the equivalence relation generated by the given relation.