Skip to content

Instantly share code, notes, and snippets.

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
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
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)
@orbitz
orbitz / crap.ml
Created April 7, 2011 22:04 — forked from apg/crap.scm
let fact =
let rec fact' accum = function
| 0
| 1 -> accum
| n -> fact' (accum * n) (n - 1)
in
fact' 1
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")] }
success, value = json.loads(result)
if success:
handle_success(value)
else:
handle_error(value)
match json.loads result with
(true, value) -> handle_success value
| (false, error) -> handle_error error
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))
})
}