F#

Performance Test – SortedDictionary vs Dictionary vs Map vs Array

I stumbled upon this interesting question on StackOverflow today, Jon Harrop’s answer mentions a significant overhead in adding and iterating over a SortedDictionary and Map compared to using simple arrays. Thinking about it, this makes sense, the SortedDictionary class sorts its constituent key-value pairs by key, which will naturally incur some performance overhead. F#’s Map …

Performance Test – SortedDictionary vs Dictionary vs Map vs Array Read More »

Project Euler – Problem 65 Solution

Problem The square root of 2 can be written as an infinite continued fraction. The infinite continued fraction can be written, ?2 = [1;(2)], (2) indicates that 2 repeats ad infinitum. In a similar way, ?23 = [4;(1,3,1,8)]. It turns out that the sequence of partial values of continued fractions for square roots provide the …

Project Euler – Problem 65 Solution Read More »

AOP with F# – Memoization using higher-order functions

I touched on the topic of memoization in the past in relation to doing aspect-oriented programming with PostSharp, however, with functional languages like F#, Haskell or Erlang there is no such frameworks (although PostSharp should still work with F# to some extent) to help you. That’s not to say that you can’t do AOP in …

AOP with F# – Memoization using higher-order functions Read More »

F# – Enums vs Discriminated Unions

In my previous post on discriminated unions, I presented discriminated unions as an alternative to standard .Net classes to represent hierarchical data structures. However, in terms of data structure, discriminated unions share much more similarities with enums than they do classes – both allow you to define a set of named constants and associate some …

F# – Enums vs Discriminated Unions Read More »

F# – Referential equality for tuples, discriminated unions and records

By default, tuples, discriminated unions and records have what is known as structural equality – i.e. if two instances of these types have the same set of values then they are considered equal, just like value types – despite being reference types: Tuples Discriminated Unions Records To facilitate this form of equality, the F# compiler …

F# – Referential equality for tuples, discriminated unions and records Read More »

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.

Close