a rather plain julia solution...

I really want to come up with a way to use multiple dispatch, but I haven't quite found it....