finds the points lying on the convex hull of the given set of points and returns those points in clockwise direction, starting at the point with minimum y-value Remarks: it's a more or less direct implementation of the algorithm named after Ronald Graham that is explained on http://en.wikipedia.org/wiki/Graham_scan you can switch the definition Point for a proper type of your liking - e.g. System.Drawing.Point
39 people like thisPosted: 13 years ago by Carsten König
Helper function to fold an operator over two sequences so {x1; x2; x3; x4; ...} and {y1; y2; y3; y4; ..} is mapped with an operator f to {f x1 y1; f x2 y2; ...} See example
20 people like thisPosted: 13 years ago by Carsten König
you can easily find how to use continuations to iterate over a binary tree but what if the count of children for each node is not known at design time? It's not so obvious how to do this in order to get a tail-recursive method. This short snippet shows how to do this to sum the values of every leaf. The second part demonstrates a general approach for other operations than addition.
26 people like thisPosted: 13 years ago by Carsten König
calculating the distance between two locations on earth using haversine formula see http://en.wikipedia.org/wiki/Haversine_formula and implementing it using the posibilities of F#'s unit of measure system to avoid unit-conversion-errors concerning radians convertet the code found here: http://www.movable-type.co.uk/scripts/latlong.html for an concrete implementation
4 people like thisPosted: 12 years ago by Carsten König
computes the list of all permutations of a list for example the permutations of [1;2;3] will be [1;2;3]; [1;3;2]; [2;1;3]; [2;3;1]; [3;1;2]; [3;2;1]
2 people like thisPosted: 12 years ago by Carsten König
Helpers to convert functions that take a 2-tuple to curried functions and vice versa. Very helpfull for the "Zip"-functor together with operators - see example
45 people like thisPosted: 13 years ago by Carsten König
shows a simple implementation of a vector and matrix type together with a QR-decomposition using the Gram-Schmidt method. The algorithms themselfes are rather easy but I think the implementation of the types and the computations using recursive techniques might be interessting
3 people like thisPosted: 13 years ago by Carsten König
it's allways a pain to work with F#'s Option values outside of F# - there you've got the Nullable-class this is a short snippet to convert Nullable<'a> to 'a option
2 people like thisPosted: 13 years ago by Carsten König
for all those wanting to see the (rather unknown) statical interference of type-parameters (in contrast to generic type parameters) in action. I demonstrated this by having som e fun with basic algebra and polynoms
0 people like thisPosted: 12 years ago by Carsten König
Found an very good article on RS-Trees in Haskell (see: http://www.eecs.usma.edu/webs/people/okasaki/jfp99.ps) It heavyly uses pattern recognition to translate those pesky balance-rules into short code. Bellowe is the simple rewrite of the haskell-implementation in F# - enjoy
6 people like thisPosted: 12 years ago by Carsten König