This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module ToyTypeInfer | |
type Var = string | |
type Expr = | |
| ENum of int | |
| EBool of bool | |
| EVar of Var | |
| EPlus of Expr * Expr | |
| EIf of Expr * Expr * Expr |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
open FSharpx.Continuation | |
//from http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.11.3425 | |
type DelimitedCont<'A,'B>() = | |
let metaCont = ref Unchecked.defaultof<'A -> Cont<'A, 'B>> | |
member private this.Abort (thunk:Cont<'A,'B>):Cont<'A,'B> = | |
cont { | |
let! v = thunk | |
return! !metaCont v |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ql:quickload :cl-cont) | |
(ql:quickload :alexandria) | |
(ql:quickload :fare-matcher) | |
(defpackage :reify-reflect | |
(:use :cl :cl-cont :fare-matcher :fare-matcher-extensions) | |
(:import-from :alexandria :iota)) | |
(in-package :reify-reflect) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(use 'delimc.core) | |
(use 'clojure.contrib.monads) | |
(defmacro reify [thunk] | |
`(reset | |
(m-result ~thunk))) | |
(defmacro reflect [meaning] | |
`(shift k# | |
(m-bind ~meaning k#))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ql:quickload :pipes) | |
(ql:quickload :cl-cont) | |
(ql:quickload :cl-monad-macros) | |
(defpackage :llmonad | |
(:use :cl :pipes :cl-cont :cl-monad-macros)) | |
(in-package :llmonad) | |
(defun pipe-tail-no-cache (pipe) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function callcc(f) { | |
return f(new Continuation()); | |
} | |
importPackage(java.util); | |
var metaCont = new java.util.Stack(); | |
function abort(thunk) { | |
return metaCont.peek()(thunk()); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun %walker (code test result &optional (cons-fn #'cons)) | |
(labels ((iter (code) | |
(if (consp code) | |
(if (and (consp (car code)) (funcall test (car code))) | |
(funcall cons-fn | |
(funcall result (car code)) | |
(iter (cdr code))) | |
(cons | |
(iter (car code)) | |
(iter (cdr code)))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import scalaz.Forall | |
case class Record(x : List[Int], y : List[Double]) | |
def lift( | |
f: Forall[({type X[A] = (List[A], List[A]) => List[A]})#X], | |
a: Record, | |
b: Record | |
): Record = | |
(a, b) match { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import math.{pow, log, sqrt} | |
import java.util.Random | |
import org.apache.commons.math.stat.StatUtils.mean | |
import org.apache.commons.math.stat.regression.SimpleRegression | |
object HurstExponent extends App { | |
def hurstExponent(xs: Array[Double]): Double = { | |
def S(xs: Array[Double]): Double = { | |
val meanXs = mean(xs) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trait Nat { | |
type IsZero <: Bool | |
type Prev <: Nat | |
type Divisable[A <: Nat] = DivisableImpl[A, A] | |
type DivisableImpl[A <: Nat, B <: Nat] <: Bool | |
} | |
trait Z extends Nat { | |
type IsZero = True | |
type Prev = Nothing |