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 Base | |
let left x = `Left(x) | |
let right x = `Right(x) | |
let change a b = `Change(a, b) | |
let rec diff_seqs ?(acc = []) s0 s1 = | |
let cmp = Poly.compare in | |
let v_eq = Poly.equal in | |
match Sequence.next s0, Sequence.next s1 with |
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
(* Stringify (WIP) | |
------------------------------------------------------------------ | |
Generic, type-safe [to_string] utility. | |
Made for fun while reading about GADTs in Ocaml :-) | |
GADT References: | |
- https://en.wikipedia.org/wiki/Generalized_algebraic_data_type | |
- https://caml.inria.fr/pub/docs/manual-ocaml/extn.html#s%3Agadts | |
- https://blog.janestreet.com/why-gadts-matter-for-performance/ |
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 Core | |
(* Creates an ascii table from a 2D list mtx of strings. *) | |
let make_tbl data = | |
(* common vars *) | |
let (fold, map, map2) = List.(fold, map, map2_exn) in | |
let (sep_h, sep_v, sep_x) = ('-', '|', '+') in | |
let text_pad = 2 in | |
(* compute max length of each column in tbl *) |
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
{ | |
/* | |
============================== | |
Base Config | |
============================== | |
*/ | |
"workbench.activityBar.visible": true, | |
"workbench.statusBar.visible": true, | |
"editor.tabSize": 2, | |
"editor.rulers": [80], |
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
/* | |
See: http://2ality.com/2017/12/functions-reasonml.html#operators | |
*/ | |
module MapOps { | |
module HashMap = Belt.HashMap.String; | |
let ( @@ ) = (map, key) => { | |
map | |
|> HashMap.get(_, key) | |
|> Belt.Option.getExn |
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
/** | |
* Class test: | |
* --------------- | |
* (see: https://v1.realworldocaml.org/v1/en/html/classes.html) | |
*/ | |
class stack ('a) (init) = { | |
as _self; | |
val mutable v: list('a) = init; | |
pub pop = () => { |
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
/* | |
ocaml src: https://bucklescript.github.io/bucklescript/api/Belt.html | |
*/ | |
/* base type */ | |
type intTuple = (int, int); | |
/* hashable tuple */ | |
module TupleHashable = Belt.Id.MakeHashable({ |
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
const { log } = console; | |
const SPACE = " "; | |
const isString = (val) => typeof val === 'string' || val instanceof String; | |
/** | |
* Justify Text | |
* ============ | |
* TODO: description | |
*/ |
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
/** | |
* Game of Life in Reason.ml | |
* ========================= | |
*/ | |
/** | |
* Coord | |
*/ | |
module Coord = { | |
/* Type defs: */ |
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
// run | |
const ctx = initCtx(); | |
const text = `hello my friends`; | |
draw({ size: 16, fontFace: `monospace` }, text, 10, 50); | |
// initialize canvas context | |
function initCtx(w = 600, h = 400) { | |
// create canvas & ctx | |
const canvas = document.createElement('canvas'); | |
document.body.appendChild(canvas); |
NewerOlder