Skip to content

Instantly share code, notes, and snippets.

@dvanhorn
dvanhorn / 0cfa-church.rkt
Created October 3, 2012 06:23
0CFA in the AAM style on some hairy Church numeral churning
#lang racket
;; 0CFA in the AAM style on some hairy Church numeral churning
;; Moral: per machine-state store polyvariance is not viable,
;; but with widening it's not so bad.
;; (X -> Set X) -> (Set X) -> (Set X)
(define ((appl f) s)
(for/fold ([i (set)])
@lqdc
lqdc / viterbi.jl
Created April 24, 2013 04:44
Viterbi implementation in Julia Language
# Author: Roman Sinayev
# License: BSD Style.
# Viterbi algorithm implementation and example written in Julia Language
#
# The idea is to decode the most probable order of a hidden markov model
# based on indirect observations.
# In the example below, we attempt to determine where a person is based on
# their cell phone service strength. We also have fake probabilities associated
# with each state(location) and with transitions between locations and with
@sbos
sbos / HMM.jl
Created November 1, 2013 11:25
Hidden Markov Model in Julia
module HMM
using Distributions
import Distributions.rand
import Distributions.fit
immutable HiddenMarkovModel{TP, K}
theta::Vector{TP}
A::Matrix{Float64}
@owainlewis
owainlewis / Treap.hs
Created December 11, 2013 22:07
Treap in Haskell
import Control.Monad
import Data.Char
import qualified Data.List.Key as K
import System.Random
data Treap k a = Nil | Node Int k a (Treap k a) (Treap k a)
priority :: Treap k a -> Int
priority Nil = -1
priority (Node p _ _ _ _) = p
@yurivish
yurivish / Treap.jl
Last active August 29, 2015 14:01
A Julia implementation of a treap (v6; in progress)
import Base: isempty, start, next, done, length, getindex, minimum, maximum, search, show
export Treap, TreapNode
type TreapNode{K}
priority::Float64
size::Int
key::K
left::TreapNode{K}
right::TreapNode{K}
@staltz
staltz / introrx.md
Last active August 1, 2024 08:51
The introduction to Reactive Programming you've been missing
@lwhjp
lwhjp / factorial.rkt
Created October 19, 2014 08:18
Factorials in Racket
#lang racket
;;
;; These are some examples of different ways to compute factorials
;; using various paradigms and features provided by Racket. There
;; are more options available in packages which are not imported
;; by default, but that rabbit hole goes very deep indeed.
;;
;; Comments and suggestions welcome!
;; leo@lwh.jp
@dyokomizo
dyokomizo / Prefixed.rkt
Last active August 29, 2015 14:07
Interpreter for a polish notation "stack" language
#lang racket
(define eval [lambda (p ) (eval/s p '())])
(define eval/s [lambda (p s) (eval/k p s (lambda (x) x))])
(define eval/k
[lambda (p s k)
(cond {(eq? p '()) (k s)}
{(number? (car p)) (eval/k (cdr p) s [lambda (s) (k (cons (car p) s))])}
{(eq? (car p) 'dup) (eval/k (cdr p) s [lambda (s) (k (cons (car s) (cons (car s) (cdr s))))])}
@jyp
jyp / Organ.lhs
Last active September 16, 2015 09:21
---
title: On the Duality of Streams
subtitle: How Can Linear Types Help to Solve the Lazy IO Problem?
author:
- name: Jean-Philippe Bernardy
- name: Josef Svenningsson
...
<!--
@darius
darius / RABBIT.scm
Last active February 13, 2020 20:39
;;- -*-scheme-*-
;;; rabbit compiler
;;- This is the source code to the RABBIT Scheme compiler, by Guy Steele,
;;- taken from the Indiana Scheme repository and annotated by me, Darius
;;- Bacon. I converted it from all-uppercase to all-lowercase and
;;- reindented it with Emacs for better readability. I've added the
;;- comments starting with either ;- or ;*. Other comments are by Steele.
;;- The ;- comments were things I'd figured out, while ;* denoted things
;;- for me to look into. (Sometimes I didn't bother to type in the answer