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 Args = struct | |
type 'a arg_spec = { name: string; desc: string; of_string: (string -> 'a) } | |
exception RequiredArgMissing of string (* name *) | |
exception BadArgValue of string * string (* name, value *) | |
let find_given_value spec = | |
(* TODO allow user to specify argv *) | |
let arg_list = Array.to_list Sys.argv in | |
let flag = "-" ^ (spec.name) in | |
let rec find_value_in = 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
let rec next_line seen = | |
let line = read_line () in | |
if not (List.mem line seen) then print_endline line; | |
next_line (line :: seen) | |
in | |
try next_line [] with End_of_file -> () |
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
open Batteries_uni | |
open List | |
type cell = Dead | Alive | |
type grid = cell list list | |
let set_value grid (row,col) value = | |
let old_row = at grid row in | |
let new_row = (take col old_row) @ [value] @ (drop (col + 1) old_row) in | |
(take row grid) @ [new_row] @ (drop (row + 1) grid) |
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
all: spec | |
spec: game.cmo spec.ml | |
ospecl spec.ml | |
game.cmo: | |
ocamlc -c game.ml | |
clean: | |
rm *.cm* |
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
(function() { | |
var snap = function(filename) { | |
return new Continuation() | |
} | |
var top = {}; | |
load.call(top, 'env.rhino.js'); | |
load.call(top, 'jquery-1.4.2.js'); | |
top.window.location = 'page.html'; | |
top.__context__ = 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
open List | |
let num_devs = 20 | |
let failure_rate = 0.20 | |
let build_time = (15. (* mins *) /. 60.) (* hours *) | |
let commit_wait_timeslots = 4. /. build_time (* on average *) | |
let working_hours = 8. | |
let num_timeslots = working_hours /. build_time |> int_of_float | |
type build_status = Idle | Building | Pass | Retry | Fail |
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
open Batteries | |
let rec files path = | |
if Shell.is_directory path then | |
path |> Shell.readdir |> Array.enum |> map ((^) (path ^ "/")) |> map files |> Enum.flatten | |
else | |
Enum.singleton path | |
let read_file filename = | |
File.with_file_in filename IO.read_all |
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
let empty key = None | |
let put key value lookup = | |
(fun k -> if (k = key) then Some value else (lookup k)) | |
(* use *) | |
let (|>) x f = f x | |
let lookup = empty |> put "a" 1 |> put "b" 2 |> put "c" 3;; |
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 chop(needle : Int, haystack : Array[Int]) : Int = { | |
if (haystack.length == 0) return -1 | |
val midPoint = haystack.length / 2 | |
val midValue = haystack(midPoint) | |
if (midValue == needle) | |
midPoint | |
else if (needle < midValue) | |
chop(needle, haystack.slice(0, midPoint)) | |
else |
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
function mixable() { | |
var parents = []; | |
return { | |
mixin: function(parent) { parents.push(parent); }, | |
__noSuchMethod__: function(id, args) { | |
for each (var parent in parents) { | |
if (typeof parent[id] === 'function') { | |
return parent[id].apply(this, args); | |
} | |
} |
NewerOlder