Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am gian on github.
  • I am gian (https://keybase.io/gian) on keybase.
  • I have a public key whose fingerprint is 56CA 85D1 8F39 0D1C 75DC 5ED5 91DD 6D6E EF1D F469

To claim this, I am signing this object:

@gian
gian / m.sml
Created December 5, 2012 02:16
Pcomp'08 Problem M (... 4 years later)
structure M =
struct
open MParser
fun pp (Int i) = Int.toString i
| pp (Var n) = n
and plist [h] = pp h
| plist t = String.concatWith ":" (map pp t)
fun put e k (v : exp list) = (k,v) :: e
fun ap (h::l) =
let
fun allpairs h [] = []
| allpairs h (h'::t) = (h,h') :: allpairs h t
in
List.foldl (fn (a,b) => b @ allpairs a l) [] (h::l)
end
%name P1;
%name P2;
%name P3;
%name P4;
%name P5;
%name F1;
%name F2;
%name F3;
%name F4;
@gian
gian / gist:775955
Created January 12, 2011 09:57
BAM definitions
structure Syntax =
struct
open Set
type control = {name : string, active : bool, index : int option}
val fresh = ref 0
fun freshIndex {name=name, active=active, index=_} =
{name=name, active=active, index=SOME (fresh := !fresh + 1; !fresh)}
if(s1.type == SYM_ANY) {
if(s1.kind == KIND_NODE) {
if(s2.type == SYM_ANY) {
if(s2.kind == KIND_NODE) {
return TRUE;
} else {
return s1.kind == s2.kind;
}
} else {
return TRUE;