Very nicely done. Thanks!<p>Just scanning the code, I think showing C++ rocks is pretty much a no-brainer (ducks to avoid food fight) but part of what's happened here, I'll bet, is that you've stayed within the default heap size allocated by the compiler.<p>It's just a nit, and it's an easy fix too, but I wanted to point that out. The .NET examples are probably doing some mem-safe allocations each trip around, while the C++ is just burning through what it already has.<p>Also there's another point that needs to be drawn out: your code is much cleaner in imperative because you've solved it functionally first. Most imperative programmers wouldn't write anything that looked like what you did. OO guys would still be constructing object graphs. The language you choose plays a major role in how you solve problems.<p>As far as the F# speed difference, I've struggled with staying with F# or moving on to OCaml. Right now, I think I'd rather have more libraries and slower speed, so I'm staying with F#. For some reason OCaml seems to be a tougher language to pick up -- the community is a bit scattered and finding help on easy topics isn't easy (at least for me). Plus I like the fact that a lot of stuff developed in Windows for .NET can just plop over in linux and still work. That's worth a bit of speed.<p>And in any case, if it wasn't, if your code is clean you can move fairly easily between OCaml and F#.