Skip to content

Instantly share code, notes, and snippets.

View Drup's full-sized avatar

Gabriel Radanne Drup

View GitHub Profile
use std::cmp::Ordering;
enum Tree<T: Ord> {
Node {v: T, left: Box<Tree<T>>, right: Box<Tree<T>>},
Empty,
}
impl<T: Ord> Tree<T> {
fn find(&self, target: T) -> bool {
@Drup
Drup / .gitignore
Last active February 19, 2021 12:42
OCaml typechecker AVL Log postprocessing
_build/
@Drup
Drup / code.ml
Created January 26, 2021 15:00
GATDs gone mild
(** Supporting code for the "GADTs gone mild" talk *)
(** Compact Arrays
https://blogs.janestreet.com/why-gadts-matter-for-performance/
*)
module CompactArray = struct
type 'a t =
| Array of 'a array
| String of string
type atom = Char.t
let compare_atom = Char.compare
module AMap = CCMap.Make(Char)
(** Regular expressions *)
module Re = struct
module rec Internal : sig
type t =
| Epsilon
from TreeVisitor import TreeVisitor
class MyTreeVisitor(TreeVisitor):
def visitLeaf(self, ctx):
return True # une feuille est un A.B.
def visitNode(self, ctx):
children = ctx.int_tree()
module B = Brisk_reconciler
let constant name x =
B.Expert.nativeComponent name (fun hooks ->
( {
make = (fun () -> x);
configureInstance = (fun ~(isFirstRender : _) node -> node);
children = B.empty;
insertNode = (fun ~parent ~child:_ ~position:_ -> parent);
deleteNode = (fun ~parent ~child:_ ~position:_ -> parent);
@Drup
Drup / chronology.sty
Last active February 15, 2023 12:05
A simple package to make horizontal timeline. Taken and heavily modified from somewhere in the internet.
\NeedsTeXFormat{LaTeX2e}%
\ProvidesPackage{chronology}[2015/03/27 v1.1.1 Horizontal timeline]%
\RequirePackage{calc}%
\RequirePackage{tikz}%
\RequirePackage{xparse}%
% Defining counters and lengths
\newcounter{step}\newcounter{stepstart}\newcounter{stepstop}%
\newcounter{yearstart}\newcounter{yearstop}\newcounter{deltayears}%
\newlength{\xstart}\newlength{\xstop}%
\newlength{\unit}\newlength{\timelinewidth}%
@Drup
Drup / saccade.ml
Created August 4, 2017 15:55
A generic cascade/batseq/lazylist that works with any monad.
module type S = sig
type 'a m
val pure : 'a -> 'a m
val delayed : (unit -> 'a) -> 'a m
val map : ('a -> 'b) -> 'a m -> 'b m
val bind : 'a m -> ('a -> 'b m) -> 'b m
@Drup
Drup / sat_micro.ml
Last active June 15, 2020 17:17
SAT-MICRO, a Sat solver in 60 lines of code
(* Code extracted from:
SAT-MICRO: petit mais costaud !
by Sylvain Conchon, Johannes Kanig, Stéphane Lescuyer
*)
module type VARIABLES = sig
type t
val compare : t -> t -> int
end
@Drup
Drup / fakeformat.ml
Created April 10, 2017 17:31
Fake printer
[@@@ocaml.warning "-40"]
module CB = CamlinternalFormatBasics
module C = CamlinternalFormat
module F = Format
type ufmt = Format.formatter -> unit
(* copied from format.ml, don't ask *)