text
stringlengths
0
601k
let rec quickhull_rec : line -> points -> points -> points = fun line points hull_accum -> match points with | [ ] -> [ ] | _ -> let pivot_point , _ = furthest_point_from_line line points in let l_line = ( fst line , pivot_point ) in let r_line = ( pivot_point , snd line ) in let l_points = List . filter ( line_side_te...
let quickhull : points -> points = fun points -> let p_min_x = List . fold_left ( fun p q -> if ( fst p ) < ( fst q ) then p else q ) ( max_float , 0 . 0 ) points in let p_max_x = List . fold_left ( fun p q -> if ( fst p ) > ( fst q ) then p else q ) ( min_float , 0 . 0 ) points in let line_above = ( p_min_x , p_max_x ...
let rec qsort lo hi ( a : int array ) = if lo < hi then begin let i = ref lo in let j = ref hi in let pivot = a . ( hi ) in while ! i < ! j do while ! i < hi && a . ( ! i ) <= pivot do incr i done ; while ! j > lo && a . ( ! j ) >= pivot do decr j done ; if ! i < ! j then begin let temp = a . ( ! i ) in a . ( ! i ) <- ...
let cmp i j = i - j
let rec qsort2 lo hi ( a : int array ) = if lo < hi then begin let i = ref lo in let j = ref hi in let pivot = a . ( hi ) in while ! i < ! j do while ! i < hi && cmp a . ( ! i ) pivot <= 0 do incr i done ; while ! j > lo && cmp a . ( ! j ) pivot >= 0 do decr j done ; if ! i < ! j then begin let temp = a . ( ! i ) in a ...
let seed = ref 0
let random ( ) = seed := ! seed * 25173 + 17431 ; ! seed land 0xFFF
let test_sort sort_fun size = let a = Array . make size 0 in let check = Array . make 4096 0 in for i = 0 to size - 1 do let n = random ( ) in a . ( i ) <- n ; check . ( n ) <- check . ( n ) + 1 done ; sort_fun 0 ( size - 1 ) a ; try check . ( a . ( 0 ) ) <- check . ( a . ( 0 ) ) - 1 ; for i = 1 to size - 1 do if a . (...
let main ( ) = test_sort qsort 50000 ; test_sort qsort2 50000
let _ = main ( ) ; exit 0
let main ~ ctxt ( qckstrt_lvl , interf , setup_data ) oasis_fn = let post_run ( ) = let pkg = OASISParse . from_file ~ ctxt oasis_fn in Setup . main ~ ctxt setup_data oasis_fn pkg in OASISQuickstart . to_file ~ ctxt oasis_fn qckstrt_lvl interf post_run
let fspecs ( ) = let ( specs , anon ) , gen = Setup . fspecs ( ) in let lvls = [ " beginner " , Beginner ; " intermediate " , Intermediate ; " expert " , Expert ; ] in let qckstrt_lvl = ref Beginner in let interf = ref Human in let specs ' = [ " - level " , Arg . Symbol ( ( List . map fst lvls ) , ( fun s -> qckstrt_lv...
let ( ) = CLISubCommand . register " quickstart " ( ns_ " Launch a helper to write ` _oasis ` file " ) CLIData . quickstart_mkd ( CLICommon . define_oasis_fn ( CLISubCommand . make_run fspecs main ) )
type t = { source : [ ` path of string list * string list | ` filelist of string list ] ; model : GTree . list_store ; index_0 : ( char , Gtk . tree_path ) Hashtbl . t ; index_1 : ( char , Gtk . tree_path ) Hashtbl . t ; index_c : ( char , Gtk . tree_path ) Hashtbl . t ; index_cc : ( string , Gtk . tree_path ) Hashtbl ...
let models : ( string * t ) list ref = ref [ ]
let re_dot = !~~ " . " ; ;
let re_question = !~~ " " ; ; ?
let re_asterisk = !~~ " " ; ; *
let re_wildcards = !~ " [ ] " ; ; ?*
let crono_sum time f x = let finally t = time := ! time . + ( Unix . gettimeofday ( ) . - t ) ; in let t = Unix . gettimeofday ( ) in let result = try f x with e -> begin finally t ; raise e end in finally t ; result ; ;
let cols = new GTree . column_list
let col_pixbuf = cols # add ( Gobject . Data . gobject_option : ( GdkPixbuf . pixbuf option ) Gobject . data_conv )
let col_name = cols # add Gobject . Data . string
let col_path = cols # add Gobject . Data . string
let col_visible = cols # add Gobject . Data . boolean
let create_model ~ source ~ name = let model = GTree . list_store cols in let model = { source = source ; model = model ; index_0 = Hashtbl . create 17 ; index_1 = Hashtbl . create 17 ; index_c = Hashtbl . create 17 ; index_cc = Hashtbl . create 17 ; index_icons = [ ] ; index_removed = [ ] ; filenames = Hashtbl . creat...
let char_contained str = let res = ref [ ] in String . iter ( fun c -> if not ( List . mem c ! res ) then res := c :: ! res ) ( String . sub str 1 ( String . length str - 2 ) ) ; ! res ; ;
let regexp_of_pattern pattern = let pattern = ( Str . global_replace re_dot " . " \\ pattern ) in let pattern = ( Str . global_replace re_question " . " pattern ) in let pattern = ( Str . global_replace re_asterisk " [ -+ ' a - zA - Z ( ) ; . , !^%&$@# _0 - 9 ] " * pattern ) in Miscellanea . regexp_case_fold pattern ; ...
let init ~ roots ~ filter = let widget = new widget ~ source ( ` : path ( roots , [ ] ) ) ~ name " " : ~ filter ( ) in widget # update_model ~ blocking : true ( ) ; ;
let add_roots ~ roots ~ filter = let name = " " in match List_opt . assoc name ! models with | Some model -> models := List . remove_assoc name ! models ; begin match model . source with | ` path ( rr , filelist ) -> let roots = rr @ roots in init ~ roots ~ filter | _ -> assert false end | _ -> init ~ roots ~ filter
let debug fmt = Logging . debug " quota " fmt
let info fmt = Logging . info " quota " fmt
let warn fmt = Logging . warn " quota " fmt
let maxent = ref ( 10000 )
let maxsize = ref ( 4096 )
let maxwatch = ref 50
let maxtransaction = ref 20
let maxwatchevent = ref 256
type overrides = ( int , int ) Hashtbl . t
let maxent_overrides = Hashtbl . create 10
let maxwatch_overrides = Hashtbl . create 10
let maxtransaction_overrides = Hashtbl . create 10
let maxwatchevent_overrides = Hashtbl . create 10
let get_override t domid =
let set_override t domid override = match override with
let of_domain t default domid =
let maxent_of_domain = of_domain maxent_overrides maxent
let maxwatch_of_domain = of_domain maxwatch_overrides maxwatch
let maxtransaction_of_domain = of_domain maxtransaction_overrides maxtransaction
let maxwatchevent_of_domain = of_domain maxwatchevent_overrides maxwatchevent
type t = { }
let copy quota = { cur = ( Hashtbl . copy quota . cur ) }
let del quota id = Hashtbl . remove quota . cur id
let check quota id size = )
let get quota id =
let set quota id nb = else end
let decr quota id =
let incr quota id =
let union quota diff =
let merge orig_quota mod_quota dest_quota = Hashtbl . iter ( fun id nb -> let diff = nb - ( get orig_quota id ) in if diff <> 0 then set dest_quota id ( ( get dest_quota id ) + diff ) ) mod_quota . cur
module Make ( Ast : Sig . Camlp4Ast ) module Ast = Ast ; module DynAst = DynAst . Make Ast ; module Loc = Ast . Loc ; open Format ; open Sig ; type expand_fun ' a = Loc . t -> option string -> string -> ' a ; module Exp_key = DynAst . Pack ( struct type t ' a = unit ; end ) ; module Exp_fun = DynAst . Pack ( struct typ...
let header current categories pages = let aux short = let long = match Category . find short with | None -> failwith ( " cannot find category " ^ short ) | Some c -> c in let url = try let first = List . find ( fun p -> p . Page . category = Some short && p . Page . id = 1 ) pages in first . Page . permalink with Not_f...
let footer current categories pages = let categories = List . map ( fun short -> let long = match Category . find short with | None -> failwith ( " cannot find category " ^ short ) | Some c -> c in short , long , List . sort Page . compare ( List . filter ( fun p -> p . Page . category = Some short ) pages ) ) categori...
let ( |> ) a b = b a
let read t ( perms : Perms . t ) ( path : Store . Path . t ) = end end end end
let exists t perms path = try ignore ( read t perms path ) ; true with Store . Path . Doesnt_exist _ -> false
let write t creator perms path value =
let list t perms path =
let rm t perms path =
module Error = struct type t = IllTypedQuotationProblem of D . tp * D . con let pp fmt = function | IllTypedQuotationProblem ( tp , con ) -> Format . fprintf fmt " Ill - typed quotation problem % a : % a " D . pp_con con D . pp_tp tp end
module MU = Monad . Util ( QuM )
let contractum_or x = function | ` Done -> x | ` Reduce y -> y
let guess_bound_name : D . con -> Ident . t = function | D . Lam ( x , _ ) -> x | D . BindSym ( _x , _ ) -> ` Anon | D . Cut { tp = D . Pi ( _ , x , _ ) ; _ } -> x | D . Cut { tp = D . TpSplit ( _branch :: _ ) ; _ } -> ` Anon | D . Split ( _branch :: _ ) -> ` Anon | _ -> ` Anon
let rec quote_con ( tp : D . tp ) con = QuM . abort_if_inconsistent ( ret S . tm_abort ) @@ let * veil = read_veil in let * tp = contractum_or tp <@> lift_cmp @@ Sem . whnf_tp ~ style ` : UnfoldAll tp in let * con = contractum_or con <@> lift_cmp @@ Sem . whnf_con ~ style ( ` : Veil veil ) con in match tp , con with | ...
let copy_channels ic oc = let sz = 1024 in let buf = Bytes . create sz in let rec copy ( ) = let n = input ic buf 0 sz in if n > 0 then ( output oc buf 0 n ; copy ( ) ) in copy ( )
let copy_file src dst = let ic = open_in_bin src in let oc = open_out_gen [ Open_wronly ; Open_creat ; Open_trunc ; Open_binary ] 0o777 dst in copy_channels ic oc ; close_in ic ; close_out oc
let cat_file f = let ic = open_in f in copy_channels ic stdout ; close_in ic
let myecho = Filename . concat Filename . current_dir_name " my echo . exe "
let run ? stdin ? stdout ? stderr args = flush Stdlib . stdout ; let rc = Sys . command ( Filename . quote_command myecho ? stdin ? stdout ? stderr args ) in if rc > 0 then begin printf " !!! my echo failed \ n " ; exit 2 end
let _ = copy_file " myecho . exe " " my echo . exe " ; printf " -------- Spaces \ n " ; run [ " Lorem ipsum dolor " ; " sit amet , " ; " consectetur adipiscing elit , " ] ; printf " -------- All ASCII characters \ n " ; run [ " " ' ( ) , . " ; !\#$%&*+-/ " 0123456789 " ; " ; " ; :<=>?@ " ABCDEFGHIJKLMNOPQRSTUVWXYZ " ; ...
let foo = { % foo | foooooooooooooo } |
let foo = ( { % foo | foooooooooooooo } | [ @ attr ] )
let foo = { % foo sep | foooooooooooooo | sep }
let foo = { % foo | foooooooooooooo } | [ @@ attr ]
let foo = { % foo | foooooooooooooo } | [ @@ attr ]
let foo = ( { % foo | foooooooooooooo } | [ @ attr ] ) [ @@ attr ]
let foo = ( { % foo | foooooooooooooo } | [ @ attr ] ) [ @@ attr ]
let foo = ( { % foo | foooooooooooooo } | [ @ attr ] ) [ @@ attr ]
let foo = { % foo sep | foooooooooooooo | sep } [ @@ attr ]
module type S = sig { %% M . foo | < hello { > x } } | { %% M . foo bar | < hello { >| x } | | bar } end
let ( { % M . foo | < hello { > x } } | : { % M . foo | < hello { > x } } ) | = { % M . foo | < hello { > x } } |
let ( { % M . foo bar | < hello { >| x } | | bar } : { % M . foo bar | < hello { >| x } | | bar } ) = { % M . foo bar | < hello { >| x } | | bar } { %% M . foo | < hello > { x } </ hello > } |
<: patt < ( module _ ) ; >> # else MLast . PaUnp loc ( Ploc . VaVal None ) None ; # endif MLast . PaUnp loc ( Ploc . VaVal None ) omt ; <: expr < let module _ = $ me $ in $ e $ ; >> # else MLast . ExLmd loc ( Ploc . VaVal None ) me e ; # endif <: expr < let module $ uid : s $ = $ me $ in $ e $ ; >> # else # endif # els...
type qVariantList and qVariantMap and qVariantHash and qVariantOther
type qBitmap = [ ` QBitmap | qPixmap ]
type qPolygon = [ ` QPolygon | qVector ]
type qPolygonF = [ ` QPolygonF | qVector ]
type t = | UnknownType of qVariantOther | QBitArray of qBitArray qt | QBitmap of qBitmap qt | Bool of bool | QBrush of qBrush qt | QByteArray of qByteArray qt | QChar of qChar qt | QColor of qColor qt | QCursor of qCursor qt | QDate of qDate qt | QDateTime of qDateTime qt | Double of float | QEasingCurve of qEasingCurv...
let null = UnknownType ( null ( ) )
type t = | E | Q of A . t * A . t * A . t * A . t