text stringlengths 12 786k |
|---|
let mk s = s |
let pwd = Sys . getcwd ( ) |
let add_extension ext x = x ^ " . " ^ ext |
let check_extension x ext = let lx = String . length x and lext = String . length ext in lx > lext + 1 && x . [ lx - lext - 1 ] = ' . ' && String . is_suffix x ext |
module Operators = struct let ( / ) = concat let ( . -- ) file ext = add_extension ext file end |
let equal x y = x = y |
let to_string x = x |
let is_directory x = try ( My_unix . stat x ) . My_unix . stat_file_kind = My_unix . FK_dir with Sys_error _ -> false |
let readdir x = Outcome . good ( sys_readdir x ) |
let not_normal_form_re = Glob . parse " { , . , . . } " <**//**> |
let parent x = concat parent_dir_name x |
let split p = let rec go p acc = let dir = dirname p in if dir = p then dir , acc else go dir ( basename p :: acc ) in go p [ ] |
let join root paths = let root = if root = current_dir_name then " " else root in List . fold_left ( ) / root paths |
let _H1 = assert ( current_dir_name = " . " ) |
let _H2 = assert ( parent_dir_name = " . . " ) |
let rec normalize_list = function | [ ] -> [ ] | " . " :: xs -> normalize_list xs | " . . " :: _ -> failwith " Pathname . normalize_list : . . is forbidden here " | _ :: " . . " :: xs -> normalize_list xs | x :: xs -> x :: normalize_list xs |
let normalize x = if Glob . eval not_normal_form_re x then let root , paths = split x in join root ( normalize_list paths ) else x |
let is_prefix x y = let lx = String . length x and ly = String . length y in if lx = ly then x = ( String . before y lx ) else if lx < ly then x = ( String . before y lx ) && List . mem y . [ lx ] dir_seps else false |
let link_to_dir p dir = is_link p && is_prefix dir ( readlink p ) |
let remove_extension x = try chop_extension x with Invalid_argument _ -> x |
let get_extension x = try let pos = String . rindex x ' . ' in String . after x ( pos + 1 ) with Not_found -> " " |
let update_extension ext x = add_extension ext ( chop_extension x ) |
let chop_extensions x = let dirname = dirname x and basename = basename x in try let pos = String . index basename ' . ' in dirname / ( String . before basename pos ) with Not_found -> invalid_arg " chop_extensions : no extensions " |
let remove_extensions x = try chop_extensions x with Invalid_argument _ -> x |
let get_extensions x = let basename = basename x in try let pos = String . index basename ' . ' in String . after basename ( pos + 1 ) with Not_found -> " " |
let update_extensions ext x = add_extension ext ( chop_extensions x ) |
let try_remove x = if exists x then Shell . rm x |
let print_path_list = List . print print |
let context_table = Hashtbl . create 107 |
let rec include_dirs_of dir = try Hashtbl . find context_table dir with Not_found -> dir :: List . filter ( fun dir ' -> dir <> dir ' ) ! Options . include_dirs |
let define_context dir context = let dir = if dir = " " then current_dir_name else dir in Hashtbl . replace context_table dir & List . union context & include_dirs_of dir |
let same_contents x y = Digest . file x = Digest . file y |
let f = function 1 -> 1 | 2 -> 2 | 3 -> 3 | 4 -> 4 | 5 -> 5 | 6 -> 6 | _ -> 0 |
let g = function 303 -> 1 | 401 -> 2 | _ -> 0 |
let iszero = function 0 -> true | _ -> false |
let h = function ' a ' -> " a " | ' e ' -> " e " | ' i ' -> " i " | ' o ' -> " o " | ' u ' -> " u " | _ -> " " ? |
let k = function ' ' | ' \ t ' | ' \ n ' | ' \ r ' -> " blk " | ' A ' . . ' Z ' | ' a ' . . ' z ' | ' \ 192 ' . . ' \ 255 ' -> " letr " | ' 0 ' . . ' 9 ' -> " dig " | ' ' ' ' ' ' ' ' ' ' ' ' ' ' ... |
let p = function [ | x ] | -> x | _ -> assert false |
let q = function [ | x ] | -> x | _ -> 0 |
let r = function [ | x ] | -> x | _ -> 0 . 0 |
let l = function [ ] || -> 0 | [ | x ] | -> x + 1 | [ | x ; y ] | -> x + y | [ | x ; y ; z ] | -> x + y + z | _ -> assert false = " % bytes_unsafe_set " |
let escaped = function | ' ' ' \ -> " ' " \\ | ' ' \\ -> " " \\\\ | ' \ n ' -> " \\ n " | ' \ t ' -> " \\ t " | ' \ r ' -> " \\ r " | ' \ b ' -> " \\ b " | c -> if ( ( k c ) <> " othr " ) && ( ( Char . code c ) <= 191 ... |
let _ = for i = - 5 to 10 do printf " f ( % d ) = % d \ n " i ( f i ) done ; List . iter ( fun i -> printf " g ( % d ) = % d \ n " i ( g i ) ) [ 0 ; 300 ; 303 ; 305 ; 400 ; 401 ; 402 ; 999 ] ; for i = - 2 to 2 do printf " iszero ( % d )... |
let f = function | lazy ( ) , _ , { contents = None } -> 0 | _ , lazy ( ) , { contents = Some x } -> 1 |
let s = ref None |
let set_true = lazy ( s := Some 1 ) |
let set_false = lazy ( s := None ) |
let ( ) = let _r = try f ( set_true , set_false , s ) with Match_failure _ -> 2 in printf " PR # 5992 = Ok \ n " |
let test e b = match e , b with | Foo , true -> 1 | Bar , false -> 2 | _ , _ -> 3 |
let ( ) = let r = test Bar false in if r = 2 then printf " PR # 5788 = Ok \ n " |
let test e b = match e , b with | Bar , false -> 0 | ( Foo | Bar ) , true -> 1 | Foo , false -> 2 | _ , _ -> 3 |
let ( ) = let r = test Foo false in if r = 0 then printf " PR # 5788 = Ok \ n " |
type token = | Abs | Acload | After | And | Annotate | Apply | Arc | Array | Arraymacro | Arrayrelatedinfo | Arraysite | Assign | Atleast | Atmost | Author | Basearray | Becomes | Between | Block | Boolean | Booleandisplay | Booleanmap | Booleanvalue | Borderpattern | Borderwidth | Boundingbo... |
let test_match tok = match tok with | ITEM2 ( Array , ITEM ( Rename , TLIST [ ID id ; STRING str ] ) , INT idx ) -> 1 | ITEM2 ( Cellref , TLIST [ ID id ] , TLIST lst ) -> 2 | ITEM2 ( Cell , TLIST [ ID cellid ] , TLIST lst ) -> 3 | ITEM2 ( Contents , TLIST lst1 ... |
let ( ) = printf " PR # 6646 = Ok \ n " %! |
type t = | B of int | C of int | I of t list | A00 | A01 | A02 | A03 | A04 | A05 | A06 | A07 | A08 | A09 | A10 | A11 | A12 | A13 | A14 | A15 | A16 | A17 | A18 | A19 | A20 | A21 | A22 | A23 | A24 | A25 | A26 | A27 | A28 | A29 | A30 | A31 | A32 | A33 | A34 | A35 | A36 | A37 | A3... |
let test = function | I [ A00 ; I [ I [ A00 ; I [ A00 ] ] ] ] -> 1 | I [ A00 ; I [ I [ A00 ; I [ A01 ] ] ] ] -> 2 | I [ A00 ; I [ I [ A00 ; I [ A02 ] ] ] ] -> 3 | I [ A00 ; I [ I [ A00 ; I [ A03 ] ] ] ] -> - 3 | I [ A00 ; ... |
let ( ) = assert ( test ( I [ A00 ; I [ I [ A00 ; I [ A00 ] ] ] ] ) = 1 ) ; assert ( test ( I [ A00 ; I [ I [ A20 ; I [ A00 ] ] ] ] ) = 11 ) ; assert ( test ( I [ A00 ; I [ I [ A00 ; I [ A01 ] ] ] ] ) = 2 ) ; assert ( ... |
type t6674 = | A1 | A2 | A3 | A4 | A5 | A6 | A7 | A8 | A9 | A10 | A11 | A12 | A13 | A14 | A15 | A16 | A17 | A18 | A19 | A20 | A21 | A22 | A23 | A24 | A25 | A26 | A27 | A28 | A29 | A30 | A31 | A32 | X of string |
let f = function | X _ -> true | _ -> false |
let ( ) = printf " PR # 6676 = Ok \ n " %! |
module GPR234HList = struct type _ cell = | Int : int -> int cell | Pair : int * int -> ( int * int ) cell | StrInt : string -> string cell | List : int list -> int list cell type hlist = | [ ] : hlist | ( :: ) : ' a cell * hlist -> hlist type ' b foldf = { f : ' a . ' ... |
let ( ) = GPR234HList . test ( ) |
let ( ) = printf " GPR # 234 = Ok \ n " %! |
module MPR7761 = struct let zyva msg c r = if r <> c then begin Printf . printf " ' % c ' pas bon pour % s ( should be ' % c ' ) \ n " %! r msg c end else Printf . printf " % s -> ' % c ' \ n " %! msg r module A = struct type t = . . type t += | A | B let f x y = match... |
type tlist = { x : ' a . ' a list } ; ; [ %% expect { | |
type tlist = { x : ' a . ' a list ; } } ] ; ; | ; ; [ %% expect { | } ] ; ; | |
type t = { x : ' a . ' a } ; ; [ %% expect { | |
type t = { x : ' a . ' a ; } } ] ; ; | ; ; [ %% expect { | } ] ; ; | ; ; [ %% expect { | } ] ; ; | ; ; [ %% expect { | { x " " } =* } ] ; ; | ; ; [ %% expect { | { x ` = AnyOtherTag } } ] ; ; | ; ; [ ... |
let zero_bit i bit = i land bit = 0 |
let lowest_bit x = x land - x |
let branching_bit prefix0 prefix1 = lowest_bit ( prefix0 lxor prefix1 ) |
let mask i bit = i land ( bit - 1 ) |
let match_prefix i prefix bit = mask i bit = prefix |
let equal_prefix prefix0 bit0 prefix1 bit1 = bit0 = bit1 && prefix0 = prefix1 |
let shorter bit0 bit1 = match bit0 < 0 , bit1 < 0 with | false , false -> bit0 < bit1 | true , false | false , true -> bit0 > bit1 | true , true -> assert false |
let includes_prefix prefix0 bit0 prefix1 bit1 = shorter bit0 bit1 && match_prefix prefix1 prefix0 bit0 |
let compare_prefix prefix0 bit0 prefix1 bit1 = let c = compare bit0 bit1 in if c = 0 then compare prefix0 prefix1 else c |
module type Tree = sig type ' a t type ' a is_value [ @@ immediate ] val is_value_of : ' a t -> ' a is_value val empty : ' a is_value -> ' a t val leaf : ' a is_value -> key -> ' a -> ' a t val branch : key -> key -> ' a t -> ' a t -> ' a t type ' a descr = | Empty | Leaf... |
module Set0 = struct type ' a t = | Empty : unit t | Leaf : key -> unit t | Branch : key * key * unit t * unit t -> unit t type ' a is_value = Unit : unit is_value let [ @ inline always ] is_value_of ( type a ) ( t : a t ) : a is_value = match t with Empty -> Unit | Leaf _ -> Unit... |
module _ : Tree = Set0 |
module Map0 = struct type ' a t = | Empty | Leaf of key * ' a | Branch of key * key * ' a t * ' a t type _ is_value = Any : ' a is_value let [ @ inline always ] is_value_of _ = Any let [ @ inline always ] empty Any = Empty let [ @ inline always ] leaf Any i d = Leaf ( i , d ... |
module _ : Tree = Map0 |
module Tree_operations ( Tree : Tree ) : sig open ! Tree val is_empty : ' a t -> bool val singleton : ' a is_value -> key -> ' a -> ' a t val mem : key -> ' a t -> bool val add : key -> ' a -> ' a t -> ' a t val replace : key -> ( ' a -> ' a ) -> ' a t -> ' a t val u... |
module Set = struct type elt = key type t = unit t0 and ' a t0 = ' a Set0 . t = | Empty : unit t0 | Leaf : elt -> unit t0 | Branch : elt * elt * unit t0 * unit t0 -> unit t0 module Ops = Tree_operations ( Set0 ) include Ops let empty = Empty let singleton i = Ops . singleton Unit i ( ) ... |
module Map = struct include Map0 module Ops = Tree_operations ( Map0 ) include Ops let empty = Empty let singleton i d = Ops . singleton Any i d let inter f t0 t1 = Ops . inter Any f t0 t1 let split i t = Ops . split ~ found ( : fun a -> Some a ) ~ not_found : None i t let bindings s = List . ... |
module Make ( X : sig val print : Format . formatter -> key -> unit struct module Set = struct include Set module Elt = X let [ @ ocamlformat " disable " ] print ppf s = let elts ppf s = iter ( fun e -> Format . fprintf ppf " @ % a " Elt . print e ) s in Format . fprintf ppf " [ ... |
let mib = Int64 . ( mul 1024L kib ) |
let gib = Int64 . ( mul 1024L mib ) |
let max_disk_size = Int64 . ( mul 2040L gib ) |
let sizes = [ 0L ; 4194304L ; max_disk_size ; ] |
type choice = | First | Last |
let choices = [ First ; Last ] |
let string_of_choice = function | First -> " first " | Last -> " last " |
type position = { block : choice ; sector : choice ; } |
let rec allpairs xs ys = match xs with | [ ] -> [ ] | x :: xs -> List . map ( fun y -> x , y ) ys @ ( allpairs xs ys ) |
let positions = List . map ( fun ( block , sector ) -> { block ; sector } ) ( allpairs choices choices ) |
type operation = | Create of int64 | Snapshot | Write of ( position * string ) |
let descr_of_operation = function | Create x -> [ Printf . sprintf " filename := Vhd . create ( size = % Ld ) " x ; " current := Vhd . open ( filename ) " ] | Snapshot -> [ " filename := Vhd . snapshot ( current ) " ; " current := Vhd . open ( filename ) " ... |
type program = operation list |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.