This file contains hidden or 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
(** [dir_is_empty dir] is true, if [dir] contains no files except | |
* "." and ".." | |
*) | |
let dir_is_empty dir = | |
Array.length (Sys.readdir dir) = 0 | |
(** [dir_contents] returns the paths of all regular files that are | |
* contained in [dir]. Each file is a path starting with [dir]. |
This file contains hidden or 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 hidden or 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 |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or 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
{ | |
(* short names for important modules *) | |
module L = Lexing | |
module B = Buffer | |
type token = | |
| STR of string | |
| INT of int | |
| ID of string | |
| PLUSEQ |
This file contains hidden or 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 |
This file contains hidden or 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 |
NewerOlder