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
# An implementation of Find2D-BL. | |
# | |
# Shinji Imahori, Yuyao Chien, Yuma Tanaka, and Mutsunori Yagiura. | |
# Enumerating bottom-left stable positions for rectangle placements with overlap. | |
# Journal of the Operations Research Society of Japan. Vol.57, No.1, March 2014, pp.45--61. | |
# https://www.jstage.jst.go.jp/article/jorsj/57/1/57_KJ00009350944/_article/-char/ja/ | |
from __future__ import annotations | |
from dataclasses import dataclass |
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
(* This is a short example of bindings of `chrome-launcher` and `chrome-remote-interface` | |
(for node libraries manipulating headless-mode Google Chrome) in OCaml BuckleScript (https://bucklescript.github.io/). | |
Usage: | |
$ npm install -g chrome-launcher chrome-remote-interface | |
$ bsc -bs-main bucklescript_headless_chrome.ml | |
Headless browsers (such as PhantomJS, Chrome, Firefox) are useful for, e.g., | |
- integration tests of JavaScript products on a real browser, or | |
- Web scraping for pages containing complex JavaScript. |
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
#!/usr/bin/env sh -xeu | |
## | |
## Usage: | |
## curl -sL https://gist.githubusercontent.com/akabe/24979afbf95c4cf4393f589cda997e1b/raw/install_opam.sh | sh -xeu | |
## | |
## Variables: | |
## - $OPAM_PREFIX Path to install opam | |
## - $OPAM_VERSION Version of OPAM to be installed | |
## - $OCAML_VERSION Version of OCaml to be installed |
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
#!/bin/sh -xeu | |
sudo yum install -y epel-release | |
sudo yum install -y zeromq-devel |
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
(** The Lens trick: getter and setter for fields *) | |
type ('s, 'v) lens = | |
{ | |
get: 's -> 'v; | |
set: 'v -> 's -> 's; | |
} | |
let id_lens = { | |
get = (fun x -> x); | |
set = (fun v _ -> v); |
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
object SafeList { | |
trait Z // phantom type "zero" (corresponding to 0) | |
trait S[N] // phantom type "successor" (correspoding to n => n+1) | |
class SList[N, E] private[SafeList] (private[SafeList] val list: List[E]) | |
// SList[N, E] is a list of elements of type E, and length N. | |
def empty[E] = new SList[Z, E](Nil) | |
def cons[N, E] (x: E, xs: SList[N, E]) = new SList[S[N], E](x :: xs.list) |
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 Format | |
(** The types of the source language | |
(Hindley-Milner + subtyping + bounded polymorphism) *) | |
module SL = | |
struct | |
type 'a typ = | |
| Base of 'a (** base type *) | |
| Var of string (** type variable *) | |
| Arrow of 'a typ * 'a typ (** function type *) |
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 Format | |
(** The types of the source language | |
(Hindley-Milner + subtyping + bounded polymorphism) *) | |
module SL = | |
struct | |
type 'a typ = | |
| Base of 'a (** base type *) | |
| Var of string (** type variable *) | |
| Arrow of 'a typ * 'a typ (** function type *) |
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
(* http://akabe.github.io/2015/10/GenerativePhantomTypes *) | |
#load "str.cma";; | |
(** Loads a list of integers from a file of a given path (delimiters = spaces, | |
tabs, or line feeds). *) | |
let load_list fname = | |
let re = Str.regexp "[ \t]+" in | |
let oc = open_in fname in | |
let rec aux acc = try aux (input_line oc :: acc) with End_of_file -> acc in |
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
(* http://akabe.github.io/2015/10/GenerativePhantomTypes *) | |
#load "str.cma";; | |
(** Loads a list of integers from a file of a given path (delimiters = spaces, | |
tabs, or line feeds). *) | |
let load_list fname = | |
let re = Str.regexp "[ \t]+" in | |
let oc = open_in fname in | |
let rec aux acc = try aux (input_line oc :: acc) with End_of_file -> acc in |
NewerOlder