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
type labelPixels = { label: int; pixels: int array } | |
let slurp_file name = | |
let ic = open_in name in | |
let try_read () = | |
try | |
let line = input_line ic in | |
let sline = Str.split (Str.regexp ",") line in | |
let numline = List.map int_of_string sline in | |
Some { label = List.hd numline |
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 base = 5 | |
let string_length = 8096 | |
(* Uber lame *) | |
let rec pow b = function | |
| 0 -> 1 | |
| n -> b * pow b (n - 1) | |
module Kmer = struct | |
type t = { kmer : int |
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
type silly_object = { add : (int -> unit) | |
; set : (int -> unit) | |
; get : (unit -> int) | |
};; | |
let new_silly_object v = | |
let v_ref = ref v in | |
{ add = (fun s -> v_ref := !v_ref + 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
let fact = | |
let rec fact' accum = function | |
| 0 | |
| 1 -> accum | |
| n -> fact' (accum * n) (n - 1) | |
in | |
fact' 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
R <- five.list$R - five.list$Rb | |
G <- five.list$G - five.list$Gb | |
R.sorted <- apply(R, 2, sort) | |
G.sorted <- apply(G, 2, sort) | |
R.row.means <- apply(R.sorted, 1, mean) | |
G.row.means <- apply(G.sorted, 1, mean) | |
R.fin <- R.sorted | |
G.fin <- G.sorted | |
for(x in 1:ncol(R.fin)) { R.fin[, x] <- R.row.means[rank(R[, x], ties.method="first")] } | |
for(x in 1:ncol(G.fin)) { G.fin[, x] <- G.row.means[rank(G[, x], ties.method="first")] } |
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
success, value = json.loads(result) | |
if success: | |
handle_success(value) | |
else: | |
handle_error(value) | |
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
match json.loads result with | |
(true, value) -> handle_success value | |
| (false, error) -> handle_error error |
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 partition[T](items: List[T], p: (T, T) => Boolean): List[List[T]] = { | |
items.foldRight[List[List[T]]](Nil)((item: T, items: List[List[T]]) => items match { | |
case (first :: rest) :: last if p (first, item) => | |
(List(item)) :: (first :: rest) :: last | |
case (first :: rest) :: last => | |
(item :: first :: rest) :: last | |
case _ => List(List(item)) | |
}) | |
} |