Skip to content

Instantly share code, notes, and snippets.

cat reader.js eval.js base.js mk.js test.js | node
let rec a_sock v vars vals = match (vars, vals) with
| (x :: xs, y :: ys) -> if v = x then Some y else a_sock v xs ys
| ([], []) -> None
| _ -> failwith "malformed environment"
module Eval = struct
type repr = string list -> int list -> int
let var v = fun vars vals -> match a_sock v vars vals with
| Some x -> x
| None -> failwith "var not found"
function Pair(car, cdr) {
this.car = car;
this.cdr = cdr;
}
function pairp(x) { return x instanceof Pair }
function cons(car,cdr) { return new Pair(car,cdr); }
function procedurep(x) { return x instanceof Function; }
function Var(c) { this.c = c }
@tca
tca / gist:02a1558e6e52e3a9c202
Last active August 29, 2015 14:04
almost closure conversion
#lang racket
(define bound-prims '(+ - *))
(define foo-list (gensym))
(define foo-closure 'vector)
(define (foo exp [bound bound-prims] [c 0] [frees '()] [self (gensym "SELF_")])
(match exp
;; auxilary to build lists
[`(,(== foo-list)) (list '() c frees)]
signature AUTHORITY_CONF = sig
val hash_length : int
val iterations : int
val derive_salt : int -> string -> string -> transaction int
end
signature AUTHORITY = sig
val auth_user : string -> string -> transaction (option int)
val add_user : string -> string -> transaction (option int)
end
fun iono str chr_tokens =
String.msplit {Haystack = str, Needle = chr_tokens}
fun iono_all str chr_tokens =
let fun iono_all' str chr_tokens memo =
case (iono str chr_tokens) of
Some("",c,s) => iono_all' s chr_tokens ((str1 c) :: memo)
| Some(p,c,s) => iono_all' s chr_tokens ((str1 c) :: p :: memo)
| None => List.rev (str :: memo)
in