Our most recent project in my Programming Languages class was to combine both C# and F# code to create a small program that generates all permissible words one can create with a scrabble hand.  That is to say, given 7 tiles (which are repeat in value) what are all legal scrabble words one can make with them?

The project itself wasn’t hard, though it was interesting to see how one combines different .NET languages.  For those unaware of how .NET languages work, the system is designed to compile to the Common Language Runtime (CLR) which creates an application virtual machine, thus allowing the language to remain platform neutral (well, as platform neutral one can get with a framework that ONLY runs on Windows at the moment, barring the Linux initiative to build a Linux- version).  In the CLR, all code from all languages of .NET are compiled into one single language, which allows the interaction of the languages.

Of course, this is not without it’s issues.  The primary one in this project was that F# lists are not C# lists, and thus you cannot mix them.  To get around this issue one typically uses generic IEnumerable objects when passing to/from F#/C#, converting the generic structure to the language specific structure once in the language.  Similarly, strings in C# are not strings in F#, nor are tuples.

Normally, this is about where I would post the code for how I solved the problem, but this time I decided that I would simply upload the entire project solution, since it would be hard to properly format all the code for the blog post.  Please forgive that I uploaded to rapidshare, as at the moment I do not have server space anywhere to host the file. 

About the file: 348kB, .RAR format

The solution was created in the Visual Studios 2010 Release Candidate using the .NET 4 Framework Release Candidate.  This will NOT open in VS2008 or under.  If there is a request for it I’ll create a 2008 compatible version and post it.

Download Here

 

“If you think you are worth what you know, you are very wrong.  Your knowledge today does not have much value beyond a couple of years.  Your value is what you can learn and how easily you can adapt to the changes this profession brings so often.”
– Jose M. Aguilar

Advertisement