Chris Smith's completely unique view

Algorithms, functional programming, CLR 4.0, and of course, F#!

January, 2008

Blog - About

About Chris Smith's completely unique view

Chris works as a Software Design Engineer in Test at Microsoft, where he spends his time making sure F# is the most awesome programming language ever.

  • Chris Smith's completely unique view

    fsyacc Sample on Code Gallery

    The first release is a simple four function calculator, which builds off of last week's blog post and integrates fsyacc for parsing. The net result is the ability to write simple simple expressions like "10 * 2 - 15 / 3" and get it evaluated using the order of operations....
  • Chris Smith's completely unique view

    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)”....
  • Chris Smith's completely unique view

    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#....
  • Chris Smith's completely unique view

    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. ...
Page 1 of 1 (4 items)