FSharp
There are 5 entries for the tag FSharp
While I was building the position heuristic function for Connect Four I ran into an interesting gotcha with F# pattern matching. Lets see if you see it before I tell you what it is: let rec heuristic (positions: (int * int) list) (pos: int*int) = match positions with | [] -> 0 | position::_ -> 1 + (heuristic (List.tl positions) pos) | _ -> heuristic (List.tl positions) pos Looking at it, it seems the code should tell me how often value is in position, right? Well it doesn’t! And there is...
I ran into some rather interesting numbers while trying to optimize my Connect Four implementation. Try to guess what this code will print out: let test= let stop1 = Stopwatch.StartNew() let list = [1..1000000] let bla = list |> List.fold (fun state x -> state + x) 0 stop1.Stop() let stop2 = Stopwatch.StartNew() let seq = seq{1..1000000} |> Seq.fold (fun state x -> state + x) 0 stop2.Stop() let stop3 = Stopwatch.StartNew() let arr = [|1..1000000|] let arr1 = arr|> Array.fold (fun state...
Last time we saw how to implement the basic miniMax algorithm, this time we will continue by designing game board representation. Basically I want to start out with the “simplest thing that might possibly work” and optimize from there. The simplest thing to use for this in F# is a 2 dimensional list. The problem is that we get some really bad performance for random access into them, because unlike C# Lists, called ResizeArray in F#, they really are represented by lists internally. To be precise they...
Lately there has been a lot of buzz about functional programming, mostly because it is supposed to be the cure to all of our concurrency troubles. The answer to this from MS has been to productize F#, a functional, object oriented language, running on .Net . There have been a lot of great blog posts and articles about F# in the internet, so if you are looking for a basic introduction this is not really the place. This series is supposed to fill in the whole i saw while searching for F# content. It...
Coding would be the right answer I guess, but more about that later. I will be starting out this blog with a totally useless post just to try out the GWB blogging software, so if you are reading this spare yourself the pain... Other then that I will soon start with a series on F# programming and hope to continue bringing in some .Net content. Cheers to you all and please don't flame a new blogger to much;) Technorati Tags: .Net,F#,FSharp...