So best rational approximations come from a continued fraction expansion.
A continued fraction expansion comes from the loop,
function* continuedFraction(x: number): Iterable<number> {
let n = Math.floor(x)
yield n
-- paper of the day | |
-- RJM Hughes, A Novel Representation of Lists and its Application to the Function "Reverse" | |
-- Information Processing Letters 22:141-144 (1986) | |
-- https://www.cs.tufts.edu/~nr/cs257/archive/john-hughes/lists.pdf | |
{-# LANGUAGE DeriveFunctor, DeriveFoldable #-} | |
module HughesLists where | |
import Data.Monoid | |
import Data.Foldable |
The Privilege of Buda united Hungary and Poland, similarly Buda notation unites Hungarian notation (name variables after their type) with Polish notation (use prefixes of known arity to process things without ambiguity).
Operators: the character '
is reserved for functions, and it accepts two types. Following Joel
Spolsky the first type is
the output and the second type is the input. So 'yx
is a segment of a variable name identifying
a function variable of type x -> y
.
Leading '
characters are inferred at the beginning of the variable name to make the name make sense.
I wanted to know what sorts of equal temperament systems were objectively better than others as 12-TET occupies a very distinctive place in music theory right now.
More description to come later.
Feel free to use/modify the below code under the MPLv2 license.
package parse_argo | |
import ( | |
"io" | |
"regexp" | |
"github.com/go-logfmt/logfmt" | |
"github.com/msoap/byline" | |
) |
Just a quick blog about how to represent discriminated unions, also called sum types.
A union type allows you to store one of N distinct types in the same variable. What makes it discriminated is that, if the types overlap, you should still be able to tell the cases apart.
So for example maybe we want to define a variable context
which might store either a FooContext or a BarContext or a BazContext, all of which are nullable types (for other reasons in our code, let's say). When we store a null FooContext in context
, we want context
to still be able to tell us that it's holding a FooContext, just the null version of that. That makes it a discriminated union.
These are called "sum types" because this lack of overlap means that if there were two valid values for FooContext (the null one and some global one, say), three for BarContext, and four for BazContext, the number of valid values for context
would be 2+3+4. It could have been less than this if they were allowed to "overlap