My early adventures with F#
- Posted in:
- Functional Programming
Andy Hunt & Dave Thomas suggested in their book "The Pragmatic Programmer" that you should build you knowledge portfolio, for example by learning a new language every year. Further more I've had the opportunity to listen to Andy Hunt twice over the last two years and he talked more about the subject. And during the fall and winter, it have been quite noisy about functional programming on dotnetrocks and I ended being somewhat curios about it.
So I decided to start learning a functional language and since I mostly spend my days in Visual Studio with .Net it felt easier to start with F#. And after a nice download and install experience from MS Research's F# site it was all up to me...
After a couple of tries I completed an implementation of quick sort:
let rec quicksort list = match list with |  ->  | head :: tail -> quicksort (List.filter (fun e -> e < head) tail) @ [head] @ quicksort (List.filter (fun e -> e >= head) tail)
It's not a problem I would have started with in another language, but I felt encouraged to look back in my old school books on recursive functions and it turned out really good.
My first impressions was quite nice and I got a lot of Lisp-flashbacks from my school days. But since it's rather unlike my normal C#-imperative way of thinking I felt that I needed some kind of guidance so I went away buying a book, "Expert F#" by Don Syme et al. and it really explains the whole thing. The only problem now is to find the time to try it all out...