a | b c | d
- https://simon.cedeela.fr
- @[email protected]
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
open Format | |
type tp = Ti | To | Arr of tp * tp | |
let pp_wrap condition pp_fmt fmt x= | |
if condition then | |
fprintf fmt "(%a)" pp_fmt x | |
else | |
fprintf fmt "%a" pp_fmt x |
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
(* ocamlfind opt -package sequence,benchmark -linkpkg truc.ml -o truc; ./truc*) | |
open Sequence.Infix | |
type op = | |
| Add | |
| Mult | |
| Div | |
| Minus |
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
(* ocamlfind opt -package sequence,benchmark -linkpkg truc.ml -o truc; ./truc*) | |
open Sequence.Infix | |
(* all the combinations *) | |
let rec combs = function | |
| [] -> Sequence.return [] | |
| x :: tail -> | |
Sequence.append (combs tail) (combs tail >|= fun l -> x :: l) |
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
#require "sequence";; | |
open Sequence.Infix;; | |
(* all the combinations *) | |
let rec combs = function | |
| [] -> Sequence.return [] | |
| x :: tail -> | |
Sequence.append (combs tail) (combs tail >|= fun l -> x :: l);; |
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
#require "sequence";; | |
open Sequence.Infix;; | |
let rec perms = function | |
| [] -> Sequence.return [] | |
| x :: tail -> perms tail >>= insert x | |
and insert x l = match l with | |
| [] -> Sequence.return [x] |
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
(* ocamlfind opt -g -package zarith -package containers.iter -linkpkg primes.ml -o primes *) | |
module L = CCLazy_list;; | |
let gen_int = | |
let n = ref Z.one in | |
fun () -> | |
let x = !n in | |
n := Z.succ !n; | |
Some x |
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
module G = struct | |
type 'a t = unit -> 'a option | |
let (--) i j = | |
let r = ref i in | |
fun () -> | |
if !r > j then None | |
else (let x = !r in incr r; Some x) |
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
type 'a hlist = | |
| HNil : unit hlist | |
| HCons : 'a * 'b hlist -> ('a * 'b) hlist | |
(** Description of type ['a] *) | |
type 'a ty = | |
| Int : int ty | |
| Bool : bool ty | |
| Sum : 's sum -> 's ty |