Software! Math! Data! The blog of R. Sean Bowman
The blog of R. Sean Bowman

Posts with tag “programming”

January 12 2017

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.

Read more...

November 26 2016

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.

Read more...

November 22 2016

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:

Read more...

August 02 2016

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.

Read more...

June 04 2016

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.

Read more...

April 18 2016

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 stackoverflow, 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.

Read more...

April 02 2016

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!)

Read more...

March 04 2016

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?

Read more...

February 09 2016

I have been writing some Javascript lately, mostly in my free time. Don’t ask me how I got started – Javascript is not my favorite language, let’s say, and I don’t do a lot of web stuff these days. But it’s been interesting to check out the landscape. There are more “frameworks” than you can shake a stick at, the language itself is evolving pretty quickly, and there are lots of cool things you can do in the browser that weren’t available even a couple of years ago.

Read more...

September 16 2015

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.

Read more...

August 29 2015

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.

Read more...