I hereby claim:
- I am phipsgabler on github.
- I am phipsgabler (https://keybase.io/phipsgabler) on keybase.
- I have a public key ASCsQ0akmVrVQzjf8wiXxDZf1qwTWGaGERmvjA8pxMEDmQo
To claim this, I am signing this object:
#!/usr/bin/env python3 | |
# -*- truncate-lines: t; -*- | |
# Yes, it is slow. But sufficient for small sets. | |
# Usage: | |
# | |
# > import mhs | |
# > list(mhs.mhs({9,11}, {2,3,6,9,10})) | |
# [frozenset({9}), | |
# frozenset({2, 11}), |
data Tree a = Leaf | Branch a (Tree a) (Tree a) deriving Show | |
insertLeftBalanced :: a -> Tree a -> Tree a | |
insertLeftBalanced x Leaf = Branch x Leaf Leaf | |
insertLeftBalanced x (Branch m Leaf r) = Branch m (Branch x Leaf Leaf) r | |
insertLeftBalanced x (Branch m l Leaf) = Branch m l (Branch x Leaf Leaf) | |
insertLeftBalanced x (Branch m l r) = Branch m (insertLeftBalanced x l) r | |
listToTree :: [a] -> Tree a | |
listToTree xs = foldl (flip insertLeftBalanced) Leaf xs |
library(ggplot2) | |
qq.line <- function(data, qf, na.rm) { | |
# from stackoverflow.com/a/4357932/1346276 | |
q.sample <- quantile(data, c(0.25, 0.75), na.rm = na.rm) | |
q.theory <- qf(c(0.25, 0.75)) | |
slope <- diff(q.sample) / diff(q.theory) | |
intercept <- q.sample[1] - slope * q.theory[1] | |
list(slope = slope, intercept = intercept) |
'use strict'; | |
// see: http://hackage.haskell.org/package/operational-0.2.3.2/docs/Control-Monad-Operational.html | |
// run in node, e.g.: | |
// > let free = require('./free_monads.js') | |
// undefined | |
// > free.main() | |
// Log: foo + bar: 52 | |
// test 1: [object Object] | |
// k: 10, v: foo |
module Transducers | |
import Control.Category | |
import Control.Arrow | |
data Transducer : Type -> Type -> Type where | |
T : ({r : Type} -> (b -> r -> r) -> (a -> r -> r)) -> Transducer a b | |
instance Category Transducer where | |
id = T (\cons => cons) |
// TO SEE THE PRINTLN'S, RUN `showExamples` IN THE CONSOLE | |
package object example { | |
def showExamples(): Unit = { | |
// # Basics | |
// > Goal of language: modular, functional, OO (+ Java interop) | |
// > Sophisticated hierarchies, type system, and flexible syntax | |
// # Classes | |
// ## Normal & abstract ones |
using Distributions | |
using Gadfly | |
function test() | |
@show θ = 100 * rand() | |
@show X = rand(Uniform(-θ, θ), 100) | |
ls = 0.1:0.5:100.0 | |
plot(x = ls, | |
y = broadcast(l -> loglikelihood(Uniform(-l, l), X), ls), |
using Primes | |
using BenchmarkTools | |
function σ{T}(k, n, ::Type{T} = Int) | |
result = ones(T, n - 1) | |
for p in primes(n) | |
bound = round(Int, log(n) / log(p), RoundDown) | |
pᵏ = convert(T, p)^k | |
pᵏⁱ = one(T) |
I hereby claim:
To claim this, I am signing this object: