Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View gnuvince's full-sized avatar

Vincent Foley gnuvince

View GitHub Profile
import java.util.Set;
import mclint.util.Parsing;
import ast.*;
import natlab.toolkits.analysis.core.ReachingDefs;
import natlab.toolkits.analysis.core.UseDefDefUseChain;
import natlab.toolkits.filehandling.GenericFile;
import natlab.toolkits.path.FileEnvironment;
import natlab.tame.BasicTamerTool;
import natlab.tame.tir.*;
(* Lexer *)
{
open Parser
}
let alpha = ['a'-'z' 'A'-'Z' '_']
let digit = ['0'-'9']
let alnum = (alpha | digit)
let intlit = digit+
let ident = alpha alnum*
def g(x):
return x*x
def f(x):
global f
if x == 5:
f = g
return x
print [f(x) for x in xrange(10)]
module CMap = Map.Make(struct
type t = char
let compare = Char.compare
end)
type t = Trie of (t CMap.t * bool)
let empty = Trie (CMap.empty, false)
let add word trie =
module CMap = Map.Make(struct
type t = char
let compare = Char.compare
end)
type t = Trie of (t CMap.t * bool)
let empty = Trie (CMap.empty, false)
let add word trie =
type t = node list
and node = Node of (char * node list) | Eow
let empty = []
let mem word nodes =
let len = String.length word in
(* Return the children nodes of the node containing the character c,
type nat = Zero | Succ of nat
let rec int_of_nat x =
match x with
| Zero -> 0
| Succ x' -> 1 + int_of_nat x'
let rec nat_of_int x =
match x with
| 0 -> Zero
.text
_main:
cmp %ebx, %ecx
mov $1, %eax
je equal
mov $0, %eax
equal:
ret
;; init.el
;; Vincent Foley - vfoley@gmail.com
(require 'cl)
(defmacro when-package-installed (package-name &rest body)
`(if (package-installed-p ,package-name)
(progn ,@body)
(warn "package %s is not installed" ,package-name)))
type 'a tree =
| Empty
| Node of ('a * 'a tree * 'a tree)
let rec walk_tree f tree =
match tree with
| Empty -> ()
| Node (x, left, right) ->
f x;
walk_tree f left;