class FunctionType:
def __init__(self, tyA, tyB):
self.tyA = tyA
self.tyB = tyB
def __eq__(self, other):
return self.tyA == other.tyA and self.tyB == other.tyB
This file contains 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
def permute(l) : | |
if len(l) == 1 : | |
yield l | |
else : | |
for i in range(len(l)) : | |
for j in permute(l[:i] + l[i + 1:]) : | |
yield [l[i]] + j | |
def combinations(l, r) : | |
if r == 1 : |
This file contains 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
#lang racket | |
(require parser-tools/lex | |
(prefix-in re- parser-tools/lex-sre) | |
parser-tools/yacc) | |
(provide (all-defined-out)) | |
(define-tokens a (NUM VAR)) | |
(define-empty-tokens b (+ - EOF LET IN)) | |
(define-lex-trans number | |
(syntax-rules () |
This file contains 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
// Y combinator | |
function Y(f) { | |
return ( | |
(function (x) { | |
return f(function (v) { return x(x)(v); }); }) | |
(function (x) { | |
return f(function (v) { return x(x)(v); }); }) | |
); | |
} |
This file contains 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
(* This is a demonstration of the use of the SML module system to | |
encode (Generalized Algebraic Datatypes) GADTs via Church | |
encodings. The basic idea is to use the Church encoding of GADTs in | |
System Fomega and translate the System Fomega type into the module | |
system. As I demonstrate below, this allows things like the | |
singleton type of booleans, and the equality type, to be | |
represented. | |
This was inspired by Jon Sterling's blog post about encoding proofs | |
in the SML module system: |
This file contains 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 AVL = struct | |
type height = int | |
type int = height | |
module Elt = Int32 | |
type t = Leaf | Node of t * Elt.t * t * height | |
exception Impossible | |
let height = function |
This file contains 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
#lang racket | |
(require rackunit) | |
;; A singly linked list is either | |
;; - NULL | |
;; - pointer to data and a pointer a sll | |
(struct node (data-ptr next-ptr)) | |
(define n4 (node 4 null)) |
This file contains 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
This is my short-ish tutorial on how to implement closures in | |
a simple functional language: Foo. | |
First, some boilerplate. | |
> {-# LANGUAGE DeriveFunctor, TypeFamilies #-} | |
> import Control.Applicative | |
> import Control.Monad.Gen | |
> import Control.Monad.Writer | |
> import Data.Functor.Foldable |
This file contains 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
This is ApacheBench, Version 2.3 <$Revision: 1604373 $> | |
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/ | |
Licensed to The Apache Software Foundation, http://www.apache.org/ | |
Benchmarking localhost (be patient).....done | |
Server Software: Racket | |
Server Hostname: localhost | |
Server Port: 9000 |
Title | Author(s) | Year |
---|---|---|
Intuitionistic Type Theory | Per Martin-Löf | 1984 |
On the Meanings of the Logical Constants and the Justification of the Logical Laws | Per Martin-Löf | 1996 |
[[http://mat.uab.cat/~kock/crm/h |
OlderNewer