# Shayne Fletcher

## 32 Added | 1 Magazine | 2 Followers | @shaynefletcher0 | Keep up with Shayne Fletcher on Flipboard, a place to see the stories, photos, and updates that matter to you. Flipboard creates a personalized magazine full of everything, from world news to life’s great moments. Download Flipboard for free and search for “Shayne Fletcher”

### Computing a US holiday calendar

Assume the existence of a type date and a function nth_kday_of_month with semantics described by Boost.Datetime documentation. We also assume sums …

### Pipelining with the |> operator in OCaml

Pipelining with |> in OCaml<p>Reading through Real World OCaml (which I'm really enjoying and can heartily recommend by the way), I came across this …

### Felix Circuits

A Felix "Circuit" Sieve of Eratostheses<p>Felix supports <i>Active Programming</i> by providing fibres ("f-threads") and synchronous channels ("s-channels"). …

### Build native Win32 x86_64 OCaml 4.01.0 on Windows 8.1

Native Win32 x86_64 OCaml 4.01.0 on Windows 8.1<p>Building OCaml 4.01.0 from source on Windows 8.1 seems to work just fine. The "Native Win64 port built …

### Extending OCaml in C++ - Boost.Date Time example

I aim to show just how easy it is to build on existing C++ libraries to extend OCaml. This should serve as a reasonable tutorial to get you going. …

### Powers

<i>bn</i> is familiar when <i>n</i> is a whole integer (positive or negative). Here's an algorithm to compute it.<p>It is also familiar to us when <i>c/d = n</i> that is, for <i>n</i> …

### Financial Modeling in Python : Windows 7, 64-bit ppf build status update

ppf build status update<p>Good results obtained on Windows 7 using Microsoft SDK 7.1 (msvc-10.0, x64), Boost-1.55.0, Blitz++-0.10, ActivePython-2.7.6 …

### Statistics

Some more basic functions, this time focusing on sequences of numbers. First sum.Now, arithmetic_mean follows trivially.This formulation shows …

### Power means

Before we get going, let me mention that my friends over at What does the quant say? have started a blog! This weeks post is about? You guessed it, …

### Being normal

Given the sophistication of today's financial markets, it's hard to imagine that until 1973, despite active trading since at least the 17th century, …

### Depth first search

Depth first search is an 'elementary graph algorithm'. This is a purely functional formulation.<p>Posted by<p>Shayne Fletcher at<p>10:27 PM<p>Labels: Algorithms, …

### Powerset

If <i>S</i> is a set, then <i>P(S)</i>, the 'powerset' of <i>S</i> is the set of all subsets of <i>S</i> including the empty set and <i>S</i> itself. If <i>S</i> has cardinality <i>N</i> then the …

### Cartesian product

For two sets $A$ and $B$, the Cartesian product denoted $A \times B$ is defined as the set of all ordered pairs $(a, b)$ where $a \in A$ and $b \in …

### Permutations

Combinations are selections that disregard order. The powerset <i>P(S)</i> of a set S is the set of all possible combinations of the <i>n</i> elements of <i>S</i>. There are</i> …

### Cartesian product (redux)

In this blog post we looked at programs to compute Cartesian Products. One algorithm (given here in OCaml) if you recall is<p>In that earlier post I …

### Merge sort

Here's another divide and conquer algorithm. This one is for sorting a sequence.<p>Conceptually, a merge sort works like this (see …

### Digits

Counting is a common problem in computer programming. I recently had a need for an algorithm to compute the number of base 10 digits of an integer …

### Terms With Variables (C++)

In this earlier post I showed a nifty OCaml type for modeling terms with variables for problems involving substitutions. I got interested in what it …

### Concatenation of a list of strings

Here's another fun (but probably silly) exercise. Its value I posit, is in highlighting the fundamental similarities that exist between the C++ and …

### Gaussian elimination (functional approach in Python)

Gaussian elimination<p>The goal here is to implement simple Gaussian elimination in Python, in a functional style just using tuples.<p>We view <i>(a, b, c)</i> a …

### Substitutions on terms with variables

This picks up on the earlier terms with variables blog entry. Remember the term_trav function? I'll recall it here but this time sharpen it up a bit …

### Tuple matching

Here is an algorithm that can be used to match tuples. For example, on matching (a, b, (c, d)) against (1, 2, (3, 4)) we'd hope to get the set (a = …

### Permutations of a list

Find all the permutations of a list. For example, given the list [1,2, 3] compute all of [[1, 2, 3], [1, 3, 2], [2, 1, 3], [2, 3, 1],[3, 1, 2], [3, …

### Longest increasing sub-sequence

According to this blog, "The <b>longest increasing sub-sequence</b> problem is to find a sub-sequence of a given sequence in which the sub-sequence elements …

### Sub-arrays of maximal sum

Another puzzle problem from this blog. "You are given an array of n integers, each of which may be positive, negative or zero. Give an algorithm to …

### Sieve of Eratosthenes

Find all the prime numbers less than or equal to k.<p>Python<p>Posted by<p>Shayne Fletcher at<p>9:04 PM<p>Labels: Algorithms, Python

### Terms with Variables

Cosineau and Mauny present a type suitable for modeling terms with variables convenient for applications involving variables and substitutions. It is …

### Real world OCaml

For many tasks, I find OCaml as useful as Python and like "a better C".<p>This program matches files in a directory with a provided suffix and invokes a …