Snippets created by Joel Huang

  • Use of Partial-Case with Parameters

    Depicts use of one kind of active pattern matching; partial-case with parameters.

    5 people like this

    Posted: 6 years ago by Joel Huang

  • Appending Two Lists Based on A Discriminated Union Type Using Continuation

    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 this

    Posted: 5 years ago by Joel Huang

  • Merge Sort on List

    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.

    3 people like this

    Posted: 5 years ago by Joel Huang

  • Sum of Squares Monoid

    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 this

    Posted: 5 years ago by Joel Huang

  • Formal Concept Analysis

    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 this

    Posted: 5 years ago by Joel Huang

  • An equilibrium list

    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 this

    Posted: 5 years ago by Joel Huang

  • The Dominator of Array

    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 this

    Posted: 5 years ago by Joel Huang