Tag Archives: .NET

I’m Alive! (Or, the Game of Life in F#)

Things have been pretty busy lately. Over the summer, I got my first job working as a programmer. A little over a month ago, I began attending university (first year). While the experiences thus far have been excellent on both counts, there have been a couple unfortunate downsides:

  1. I’ve barely had any time to blog. Not such an issue, since my writing sucks anyway 🙂
  2. I’ve had absolutely no time to sit down and write a game (!!!)

Surely I can’t be that busy… can I? There’s another reason: I’ve become totally addicted to functional programming. Continue reading


Caching Sequences: Quick and Dirty

In F# we have this wonderful Seq.cache function which allows us to cache the results of a Seq object (also known as IEnumerable). Unfortunately, C# has no such function, and implementing it yourself usually involves implementing an extra class to hold the data.

Continue reading

Emulating the Command Prompt in C# (Part 2)

Last post I demonstrated how to make a simple command prompt using a basic Console project. This time I’m going to show how to embed one in a window.

I’ll admit it, getting this to work was not particularly easy. I tried a number of different methods, from redirecting the output stream to parenting the console window. Redirecting the output stream didn’t work because not all of the output could be read until the program finished executing. Parenting the console window didn’t work because it wouldn’t draw correctly when I removed the border. In the end, I had to copy the text from the console buffer itself.

Hooray, more P/Invoke.

Continue reading

Emulating the Command Prompt in C#

The school I go to places ridiculous restrictions on the computers. Right clicks aside, one thing I wish above all things they hadn’t disabled was the command prompt. Ironically, the computers also have support for a number of programming languages. A friend of mine managed to emulate one using Python, and all was swell. The best part was that he coded in functionality to automatically add things to the system path. You see, we were doing quite a bit of C++/MinGW at the time… off our USBs of course.

I decided to make my own. The Python script had the added bonus of being cross platform, but it would be quite the stretch to expect every Windows machine in the world to have Python installed. I wanted my own custom command prompt. Because I rarely use Mac/Linux, .NET is installed on all up-to-date Windows machines, and it’s simply an awesome language, I decided to use C#.

Continue reading