Re.Mark

My Life As A Blog

TF#I Friday #7 : In which it isn’t really Friday but there is some F#

leave a comment »

After my simple start to an anagram solver in C#, I have a simple equivalent in F#:

let generateKey (chars : char[]) = new string(chars)
let lookup =  words |> Seq.groupBy(fun x -> generateKey(x.ToCharArray() |> Array.sort))
 

The lookup function expects a list of strings.  It works – although I’ve only tried it with fairly short lists of words.  Next exercise is to try calling this (or something like it) from C#.

Advertisements

Written by remark

June 29, 2011 at 11:45 am

Posted in .NET, Development, F#, Languages

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: