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
template <int n> | |
struct Int { static const int val = n; }; // Wrap an integer | |
template <class fst, class snd> | |
struct pair { | |
typedef fst first; | |
typedef snd second; | |
}; | |
struct nil { |
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
(* ========================================================================== * | |
* General implementation of A-star algorithm | |
* ========================================================================== *) | |
module Astar : | |
sig | |
type 'a t = | |
{ | |
cost : 'a -> 'a -> int; | |
goal : 'a; |
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
#!/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
(* 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
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
(* recursiveNeuralNetwork.ml --- Recursive Neural Networks and | |
Online Backpropagation Through Structure (BPTS) | |
[MIT License] Copyright (C) 2015 Akinori ABE | |
Compilation: | |
$ ocamlfind ocamlopt -linkpkg -package slap recursiveNeuralNetwork.ml | |
This program requires Sized Linear Algebra Library (SLAP), a linear algebra | |
library for OCaml with static size checking for matrix operations (see |
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 *) |
NewerOlder