Depicts use of one kind of active pattern matching; partial-case with parameters.
5 people like thisPosted: 10 years ago by Joel Huang
Lists are pointers to the head of list. It can be defined by a discriminated union type. Using continuation can do a tail-recursion version of appending two lists.
3 people like thisPosted: 8 years ago by Joel Huang
Merge Sort falls into 'Divide and Conquer' problem solving technique and it is a stable sorting. The worst case of running time is (nlogn). This implementation below follows the two abstract steps to achieve Merge Sort, i.e., * Recursively divide input list into two sub-lists. * Repeatedly merge the sub-lists.
5 people like thisPosted: 8 years ago by Joel Huang
Immutable stack can be implemented via Discriminated Union Type with methods like Push and Pop. The following snippet is a simple version of it.
2 people like thisPosted: 8 years ago by Joel Huang
A random pex4fun puzzle to write a snippet to merge two strings.
2 people like thisPosted: 8 years ago by Joel Huang
According to Wikipedia, the maximum sub-array problem is a programming task of finding the contiguous sub-array within a one-dimensional array of numbers (containing at least one positive number) which has the largest sum. The following is an attempt to solve this problem by using F# list rather than array.
3 people like thisPosted: 8 years ago by Joel Huang
Tomas has released their F# data analysis library called Deedle, I just got around to playing with it. It looks really cool!
4 people like thisPosted: 7 years ago by Joel Huang
A Simple Implementation of Lazy Type.
3 people like thisPosted: 8 years ago by Joel Huang
A continuation function takes the result when it is computed. Here is an implementation of sorting on List via insertion.
4 people like thisPosted: 8 years ago by Joel Huang
This snippet defines a computation builder that sums the squares of float values. It includes Combine, Zero, Yield, Delay, and For operations.
2 people like thisPosted: 8 years ago by Joel Huang
Formal Concept Analysis (FCA) is a method to determine cohesive groupings of functions and data structures, especially in program comprehension research. For example, consider an object set, O = {1,2,3,4,5,6,7,8,9,10}, and an attribute set, A = {composite,even,odd,prime,square}, we can build a lattice table that holds the relations between O and A.
2 people like thisPosted: 8 years ago by Joel Huang
An equilibrium index of this array is any integer P such that 0 ≤ P < N and the sum of elements of lower indices is equal to the sum of elements of higher indices. The following is an implementation of such equilibrium list (given the input is a list).
1 people like thisPosted: 8 years ago by Joel Huang
The dominator of array A is the value that occurs in more than half of the elements of A. It is a zero-indexed based array consisting of N integers (A [] with N length). To find the index array of the dominator from a A [], we can use a helpful function from Seq module call 'Seq.groupBy' to mitigate the implementation of a solution.
4 people like thisPosted: 8 years ago by Joel Huang