All Ordered Combos

Got a bit obsessed with this last night. The wife is gone, so I have to find something to do with myself.

Pasted Graphic

It's a bit convoluted, although not bad and nowhere near what the java implementation would look like.

OK, OK, OK, last one, I promise

Pasted Graphic 1

Nowhere near as elegant as the inject method below, but this covers both assignment and block usages, so you can pick your poison. If you pass in a block then you have linear rather than exponential memory usage, although the run time is of course equivalent.

OK, I'm done. This is my final answer.

Wait... Maybe we should add an optional argument with a default value that limits the output, to prevent inadvertently calling it with an array that will take forever to return...


You know what this blog needs? More power_set().

As luck would have it, an email got sent out to our coders list today asking about power set functionality in java. I flippantly replied with my implementation, saying that I was sure that the java equivilent would be just as elegant.

A witty exchange of emails followed (the sort of thing that makes you love working at an engineering oriented company), and Jim made the point that all the offered implementations were horribly memory inefficient. He offered an iterator-based solution in java.

Well, I for one am not going to stand here and let our favorite little programming language have its name dragged through the mud. So here was the iterative-based solution I came up with:

Pasted Graphic 2


Poked around a bit and didn't see this implementation, which actually came to me in bed last night. (Don't ask.)

Pasted Graphic 3

Dynamic Languages

I gave a Ruby talk here at Guidewire a few weeks ago, and it has been fun to see all the discussion that it has generated. I don't think there is much chance of us using Ruby in any serious way in our core applications, but it could make inroads in the periphery (support code, example integration applications, etc.)

Despite how much I love Ruby, I'm still skeptical of how well it will perform in a large system. I just don't have experience with large, dynamically typed systems, and a lot of older engineers I respect shudder at the idea. Maybe the prevalence of unit-testing will change this (Martin Fowler seems to think so.) I guess we will have to wait and see how the Rails projects turn out to provide evidence one way or the other.