Skip to content

Instantly share code, notes, and snippets.

View c-cube's full-sized avatar

Simon Cruanes c-cube

View GitHub Profile
@c-cube
c-cube / bench.ml
Created February 27, 2013 19:21
Benchmark Sequence.t against ExtLib's Enum.t
open ExtLib
(* sum of the ints in the list *)
let sum_list_seq l =
Sequence.fold (+) 0 (Sequence.of_list l)
(* sum of the ints in the list *)
let sum_list_enum l =
Enum.fold (+) 0 (List.enum l)
Performance counter stats for './zipperposition.native -calculus delayed Problems/RNG/RNG007-5.p -progress -steps 2000':
32205,421073 task-clock # 0,994 CPUs utilized
6 278 context-switches # 0,195 K/sec
26 cpu-migrations # 0,001 K/sec
17 681 page-faults # 0,549 K/sec
114 089 153 802 cycles # 3,543 GHz
51 700 780 017 stalled-cycles-frontend # 45,32% frontend cycles idle
<not supported> stalled-cycles-backend
150 913 459 037 instructions # 1,32 insns per cycle
@c-cube
c-cube / gist:5796351
Last active December 18, 2015 14:19
draft of ixSet for OCaml
class type ['a, 'b] index =
object
method name : string
method get : 'a -> 'b list
method add : 'a -> 'b -> ('a, 'b) index
method remove : 'a -> 'b -> ('a, 'b) index
method keys : ('a -> unit) -> unit
(** {2 Universal type} *)
module Univ = struct
(** This is largely inspired by https://ocaml.janestreet.com/?q=node/18 . *)
type t = {
mutable id : unit ref;
mutable store : unit -> unit;
} (** The universal type *)
type 'a embedding = {
@c-cube
c-cube / gist:9070873
Created February 18, 2014 13:22
battle plan
  1. make IO.output and IO.input structural types
  2. replace Enum by Gen (structural too)
  3. split IO into its own subpackage
  4. split Unix (and its interfaces to IO) into a subpackage
type 'a ty =
| Int: int ty
| String: string ty
| List: 'a ty -> 'a list ty
| Pair: ('a ty * 'b ty) -> ('a * 'b) ty
| Record: ('a, 'a) record -> 'a ty
and (_, _) record =
| Build : 'b -> ('b, 'r) record
| Field : ('a -> 'builder, 'r) record * string * 'a ty * ('r -> 'a) -> ('builder, 'r) record
@c-cube
c-cube / 1.ml
Last active August 29, 2015 14:15 — forked from kindlychung/1.ml
let rec take n l =
match n, l with
| 0, [] -> []
| _, [] -> raise (Invalid_argument "plop")
| _, h::t when n < 0 -> raise (Invalid_argument "drop")
| 0, _::_ -> []
| _, h::t -> h :: take (n - 1) t;;
take 2 [1; 2; 3; 4];;
take 2 [];;
@c-cube
c-cube / views.ml
Last active August 29, 2015 14:25
high-level abstractions for logic expressions
type 'a view =
| Var of string
| App of 'a * 'a list
| Lam of string * 'a
module T : sig
type t
val view : t -> t view
val var : string -> t
val app : t -> t list -> t
@c-cube
c-cube / ty.ml
Last active August 29, 2015 14:25
small `'a ty` implementation
type 'a hlist =
| HNil : unit hlist
| HCons : 'a * 'b hlist -> ('a * 'b) hlist
(** Description of type ['a] *)
type 'a ty =
| Int : int ty
| Bool : bool ty
| Sum : 's sum -> 's ty
@c-cube
c-cube / qtest.adoc
Last active September 15, 2015 17:05

QTest