Welcome to MSDN Blogs Sign in | Join | Help

Browse by Tags

All Tags » Snippets

Speech Recognition is gun and easy!

Evidently Microsoft ninjaed a new assembly into the .NET framework with the 3.0 release called System.Speech.dll. If adding speech recognition or speech synthesis to your applications sounds like fun, read on. Step 1: Train your computer The first step
Posted by ChrSmith | 4 Comments
Filed under: , ,

Pattern matching snippets

I've written up a few snippets demonstrating F# pattern matching.
Posted by ChrSmith | 3 Comments
Filed under: ,

fslex Sample

In this post I’ll focus on creating a simple program which will take advantage of fslex, and show how to generate a scanner to parse basic mathematical expressions like “1.0 / (sin pi + cos pi)”.
Posted by ChrSmith | 5 Comments
Filed under: , ,

Attachment(s): MegaCalc-fslex-sample.zip

F# Snippet - Enums and Discriminated Unions

I was writing some F# code this week and ran into problem. Consider the following code: type Thingey = This | That | SomethingElse Which looks like an enum. So I assumed that, like things inheriting from System.Enum, an instance of the type had a ToString method which did the right thing. But, alas, when I type it into the F# Interactive Console I get: > (Thingey.That).ToString();; val it : string = "FSI_0002+Thingey" The reason being is that the type Thingey is actually a Discriminated Union. In F#, to produce an Enumeration type you use the same syntax except you must explicitly provide an integer value for each member. Discriminated Unions can do a lot more than Enums in F#, but there are situations in which to use both. The following snippet shows you how to use Enums and simple Discriminated Union types in F#.
Posted by ChrSmith | 1 Comments
Filed under: ,

F# and Markov Chains, oh my!

Recently I started playing a collectable card game after some friends got me into it. (Who themselves got back into it after some friends of theirs started playing. Witness the economic potential of viral card games!) As it turns out, I am a pretty poor card player I figured I would get into the business of collecting cards. Which is fun, you can do alone, and requires no skill. I figured I would answer the question “If I started from scratch, how many booster packs would it take for me to collect the whole set”. Well, since booster packs give you cards randomly the best you can shoot for is a confidence interval.
Posted by ChrSmith | 2 Comments
Filed under: , ,

F# Snippets 01

This week I had the pleasure of writing some of our test automation infrastructure in F#. Not only does this give us a chance to dogfood the language, but it also helps us find pain points in the developer experience. For me at least, the biggest pain point right now is a lack of F# examples surrounding core syntax. But I would like to help combat this, so I've written a very simple app to show how to do basic object inheritance as well as implement an interface.
Posted by ChrSmith | 6 Comments
Filed under: ,
 
Page view tracker