My Little Garden of Code

May 14, 2014 - 13 minute read - Comments -

Drawing Happy Little Trees: tree meditation number 2

In the previous Tree Meditation we pondered some preliminary ideas about treeness. Now let’s think about how to draw our trees. Before we start, make sure you paste this tree type code from the last installment into the Try OCaml REPL: 1 type 'a tree = Empty | Leaf of 'a | Node of 'a tree * 'a * 'a tree Last time we coded our little tree using the constructors Empty, Leaf, and Node defined in our tree type:

Apr 29, 2014 - 4 minute read - Comments -

Coding Happy Little Trees: tree meditation number 1

It all started a few months ago when I created a quad-tree structure and then wanted to be able to visualize those trees with GraphViz. Thus this tree meditation was born. And who was the master of happy little trees? Bob Ross of course. So if you like, read the following in Bob’s very relaxing voice…. try not to go to sleep. Before we can code our happy little trees we need to define what a tree is: 1 # type 'a tree = Empty | Leaf of 'a | Node of 'a tree * 'a * 'a tree ;;

Mar 7, 2014 - 4 minute read - Comments -

C++ Dusty Corner number 537: 0 is sometimes a special number

I recently discovered the C++ Quiz site and figuring that it’s always good to practice C++ skills I started going through the questions. The third question I encountered gave me some pause… The question was: According to the C++11 standard, what is the output of this program? #include <iostream> void print(char const *str) { std::cout << str; } void print(short num) { std::cout << num; } int main() { print("abc"); print(0); print('A'); } Now the obvious response would be “abc065”, but I suspected there was some sort of trickery afoot here.

Apr 28, 2013 - 2 minute read - Comments -

Is Growth Really an End in Itself

I had an interview at a startup downtown this last week. This company has revenue and is selling stuff. At one point I asked the Director of Engineering: “So, is the company profitable?”. Apparently this wasn’t the right question to ask. His response was they weren’t trying to be profitable, they were trying to grow. As I was pondering this later it seemed odd to want growth over profitability. But apparently in the topsy-turvy world of venture capital funded startups this makes some kind of sense.