# Chris Smith's completely unique view

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

### About Chris Smith's completely unique view

• #### F# in 20 Minutes – Part II

Now that we have covered the basics, in minutes 8 - 14 we will cover the foundational concepts and types in F#. By the end of Part II you should be able to read F# code reasonably well. Immutability You may have noticed that I’ve been using the...
• #### F# in 20 Minutes - Part I

Edit: If you are interested in learning F#, let me take the opportunity to provide a shameless plug for my book Programming F# . Edit: Updated for the September CTP. Edit: While I certainly encourage you to read my blog, there is a great video we...
• #### Sieve of Eratosthenes in F#

If you don’t know what the Sieve of Eratosthenes is, don’t worry because a few days ago neither did I. But in short it is a very simple way to calculate prime numbers. Essentially you loop through all integers and keep a list of numbers which are known...
• #### Windows Live Writer

So I figured I’d check out Windows Live Writer and see what all the buzz is about. Update: With a plugin I can now copy from Visual Studio, huzzah! Con – Doesn’t preserve syntax highlighting when copying from Visual Studio. Pro – With This Plug...
• #### A Java to x86 compiler written in F#

A little personal information about me, I’m currently working on a masters degree at the University of Washington. And a few weeks ago I completed taking a course in Compiler Construction , where the course project was to build a simple Java compiler...
• #### Project Euler - Problem 34

Edit 2/8/2010: Updating for recent F# language changes. In our continuing series of how to solve Project Euler problems easily with F#, we now arrive at problem 34 which is defined as: 145 is a curious number, as 1! + 4! + 5! = 1 + 24 + 120 ...
• #### Shameless plug - we're hiring!

As Don and Brian have mentioned, we are working towards an April Update to the F# research release as well CTP this summer and eventually integrating into the next release of Visual Studio. Things are going great on the polishing/finalizing F# front,...
• #### Single-case Active Patterns vs Function Calls

In response to an earlier post a reader wrote: Sent From: namin Subject: (|EnsurePrefix|) -- why is it an active pattern? __________________________________ Hi Chris, I was reading your blog entry Regular Expressions via Active Patterns and...
• #### How not to reverse a list

Brian McNamara, the latest addition to our stellar F# dev team, wrote up a great blog post on some pitfalls of F#. Specifically, how if you aren't careful something as simple as reversing the items in a list can take on order O(N^2) time and potentially...
• #### Project Euler - Problem 24

Project Euler problem 24 in F# Problem 24 is defined as: A permutation is an ordered arrangement of objects. For example, 3124 is one possible permutation of the digits 1, 2, 3 and 4. If all of the permutations are listed numerically or alphabetically...
• #### How to debug compiler generated code

Edit 2/8/2010: Update for recent F# language changes James Margetson recently showed me a great tip for debugging compiler generated code. Typically the problem is that using the Visual Studio debugger all you see is the x86 disassembly of the JIT...
• #### Project Euler - Problem 19

I haven't been to Project Euler in a while, but since I'm seeing other F# folks are getting into it, I figured I'd help work to improve the average F# 'genus rating' on the site. (Currently at 11%.) The easiest one I haven't already solved is problem...
• #### How not to name types and identifiers

From the 'code which is valid but looks strange and might be removed in the next release of F#, but isn't a big deal anyways' department: Adding managed, generic .Net names as part of the inference proceedure process. #light open System.Collections...
• #### Regular Expressions via Active Patterns

In my last post I introduced Active Patterns. Sure they seem neat, but what do you actually do with them?. This post coverage how to leverage Active Patterns to make your code simpler and easier to understand. In particular, how you can use Regular Expressions in Active Patterns....
• #### Introduction to F# Active Patterns

You may have heard of Active Patterns before – typically in conjunction with the words ‘awesome’ or ‘amazing’. Active Patterns are one of the more unique language features in F# and once you get a good feel for them one of the most powerful. This post will demonstrate Active Patterns from single-case and multi-case to partial and parameterized. If it’s called an Active Pattern, you’ll see an example in this post. So let’s get started....
• #### Pattern matching snippets

I've written up a few snippets demonstrating F# pattern matching....
• #### 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....
• #### 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)”....
• #### 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#....
• #### 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. ...
• #### 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....
• #### Project Euler in F# - Problem 23

Here is a quick write-up on how to solve Project Euler’s Problem 23 in F#......
• #### Joining the F# team

I'm please to announce that starting Monday I'll be joining the F# team as (currently) the only full-time tester. I'm super-excited about this for many reasons, but the biggest is knowing what an impact I'll have. Without a doubt F# will change the .Net landscape by reaching out to a new breed developer and enabling new scenarios. As we evolve the language into a v1.0 form and build out the first set of core libraries I think people will be pleasantly surprised by the power and elegance of F#....
• #### Project Euler in F# - Problem 5

Here is a quick write-up on how to solve Project Euler’s Problem 5 in F#....