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
let rec join = function | |
| [] -> "" | |
| [x] -> x | |
| [x;y] -> x^" and "^y | |
| x::xs -> x ^ ", " ^ join xs | |
let main () = | |
let argv = Array.to_list Sys.argv in |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
(* Discussion on Hacker News: https://news.ycombinator.com/item?id=6822901 | |
*) | |
exception Error of string | |
let (@@) f x = f x | |
let error fmt = Printf.kprintf (fun msg -> raise (Error msg)) fmt | |
type result = int * int |
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
{ (* vim: set ts=2 sw=2 et: *) | |
(* This tool: | |
* - reads input from stdin line by line | |
* - seperates each line into a list of words | |
* - slides a window of size 2 over the words of a line | |
* - emits each window of words to stdout | |
* | |
* usage: chopchop [-w 2] | |
* |
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
(* | |
* filter that expands leading whitespace to tabs and but other tabs | |
* to spaces. | |
* | |
* ocamlbuild ring3fmt.native | |
*) | |
(** create a string with [n] [chr] chars *) | |
let ( ** ) chr n = String.make n chr |
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 | |
set -ex | |
VERSION="0.1.17" | |
GH="https://github.com/lindig" | |
VM="$GH/xen-test-vm/releases/download/$VERSION/test-vm.xen.gz" | |
KERNEL="xen-test-vm-${VERSION//./-}.xen.gz" | |
GUEST="/boot/guest" | |
IMG="$GUEST/$KERNEL" |
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
(* Creating a directory with a given ownership and permissions looks | |
simple until you take closer look. Many things can fail: you might | |
not have the permissions to create or modify it, the desired groups | |
and owners might not exist. | |
This library tries to be systematic about it and de-composes the | |
complex operation (implemented in [mk]) into many small operations | |
that are stringed together in a monad: [>>=] sequences operations | |
and [//=] (read as: "or-else") recovers from a previous error. |
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
==> func0.ml <== | |
module Debug = struct | |
let debug msg = Printf.eprintf "debug: %s\n" msg | |
let error msg = Printf.eprintf "error: %s\n" msg | |
end | |
let main () = | |
let argv = Array.to_list Sys.argv 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
(* | |
* ocamlbuild -pkg unix assoc_timing.native | |
* | |
* When visiting all keys in an association list, when does it | |
* make sense to build a map first? According to this, | |
* building the map is amortised for list longer than 20 to 30 | |
* elements. | |
*) | |
module Int = struct |
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
module type Monad = sig | |
type 'a t | |
val return: 'a -> 'a t | |
val bind: 'a t -> ('a -> 'b t) -> 'b t | |
end |
OlderNewer