text stringlengths 0 601k |
|---|
let px = ref 0 . 0 |
let py = ref 0 . 0 |
let points = ref [ ] |
let display ( ) = glClear [ GL_COLOR_BUFFER_BIT ; GL_DEPTH_BUFFER_BIT ] ; glLoadIdentity ( ) ; glPointSize 5 . 0 ; glBegin GL_POINTS ; List . iter ( function ( x , y , r , g , b ) -> glColor3 r g b ; glVertex2 x y ; ) ! points ; glColor3 1 . 0 1 . 0 0 . 0 ; glVertex2 ! px ! py ; glEnd ( ) ; glFlush ( ) ; glutSwapBuffer... |
let reshape ~ width : w ~ height : h = glViewport 0 0 w h ; glMatrixMode GL_PROJECTION ; glLoadIdentity ( ) ; let x_min = - 6 . 0 and x_max = 6 . 0 and y_min = - 6 . 0 and y_max = 6 . 0 and z_min , z_max = - 6 . 0 , 60 . 0 in if w <= h then glOrtho x_min x_max ( y_min . * float h . / float w ) ( y_max . * float h . / f... |
let motion ~ x ~ y = let mx , my , _ = gluUnProjectUtil ~ x ~ y in px := mx ; py := my ; ; ; |
let passive ~ x ~ y = let mx , my , _ = gluUnProjectUtil ~ x ~ y in px := mx ; py := my ; ; ; |
let mouse ~ button ~ state ~ x ~ y = let mx , my , _ = gluUnProjectUtil ~ x ~ y in px := mx ; py := my ; match button , state with | GLUT_LEFT_BUTTON , GLUT_DOWN -> let r , g , b = Random . float 1 . 0 , Random . float 1 . 0 , Random . float 1 . 0 in let pt = ( mx , my , r , g , b ) in points := pt :: ! points ; | _ ->... |
let keyboard ~ key ~ x ~ y = match key with ' q ' | ' \ 027 ' -> exit 0 | _ -> ( ) ; ; |
let idle ( ) = glutPostRedisplay ( ) ; ; ; |
let gl_init ( ) = glClearColor 0 . 5 0 . 5 0 . 5 0 . 0 ; glShadeModel GL_FLAT ; ; ; |
let ( ) = print_endline " usage : clic in the window to add a new point " ; ; ; |
let ( ) = ignore ( glutInit Sys . argv ) ; glutInitDisplayMode [ GLUT_DOUBLE ; GLUT_RGB ] ; glutInitWindowSize 600 600 ; glutInitWindowPosition 100 100 ; ignore ( glutCreateWindow Sys . argv . ( 0 ) ) ; gl_init ( ) ; glutDisplayFunc ~ display ; glutReshapeFunc ~ reshape ; glutIdleFunc ~ idle ; glutMouseFunc ~ mouse ; g... |
let classify_chars s = let rec classify_chars_at p = if p < String . length s then let c = s [ . p ] p in let cls = cls :: classify_chars_at ( p + 1 ) 1 else [ ] in classify_chars_at 0 |
let recognize_numbers l = let rec recognize_at m acc = match m with | ` Digit d :: m ' -> let d_v = Char . code d - Char . code ' 0 ' in let acc ' = match acc with | Some v -> Some ( Some10 * v + d_v ) d_v | None -> Some d_v in recognize_at m ' acc ' | x :: m ' -> ( match acc with | None -> x :: recognize_at m ' None |... |
let analysis = classify_chars |- recognize_numbers |
let number_value1 t = match t with | ` Number n -> n | ` Digit d -> Char . code d - Char . code ' 0 ' |
let number_value2 t = match t with | ` Number n -> n | ` Digit d -> Char . code d - Char . code ' 0 ' | _ -> failwith " This is not a number " |
type classified_char = [ ` Digit of char | ` Letter of char | ` Other of char ] |
type number_token = [ ` Digit of char | ` Number of int ] |
type classified_number_token = [ classified_char | number_token ] |
let rec sum l = match l with | x :: l ' -> ( match x with | ` Digit _ | ` Number _ -> number_value1 x + sum l ' | _ -> sum l ' ) | [ ] -> 0 |
let rec sum2 l = match l with | x :: l ' -> ( match x with | ( ` Digit _ | ` Number _ ) _ as y -> number_value1 y + sum2 l ' | _ -> sum2 l ' ) | [ ] -> 0 |
let rec sum3 l = match l with | # number_token as y :: l ' -> number_value1 y + sum3 l ' | _ :: l ' -> sum3 l ' | [ ] -> 0 |
module PZ_q ( Z_q : Znz . ZN ) : sig type t module Z_q : Znz . ZN val eval : p : t -> x : Z_q . t -> Z_q . t val of_list : Z_q . t list -> t end module Z_q = Z_q type t = Z_q . t list let eval ~ p ~ x = List . fold_right ( fun c y -> Z_q . ( ( y * x ) + c ) ) p Z_q . zero let of_list l = l end |
module type CYCLIC_GROUP = sig type t val pp : Format . formatter -> t -> unit include Compare . S with type t := t include S . RAW_DATA with type t := t include S . B58_DATA with type t := t include S . ENCODER with type t := t val name : string module Z_m : Znz . ZN val e : t val g1 : t val g2 : t val ( * ) : t -> t ... |
module type DLEQ = sig type equation type proof val proof_encoding : proof Data_encoding . t type element type exponent val setup_equation : element -> element list -> element list -> element list -> equation val make_proof : equation -> exponent list -> proof val check_proof : equation -> proof -> bool end |
module MakeDleq ( G : CYCLIC_GROUP ) : DLEQ with type element = G . t and type exponent = G . Z_m . t = struct type element = G . t type exponent = G . Z_m . t type equation = element * element list * element list * element list type proof = exponent * exponent list let proof_encoding = Data_encoding . ( tup2 G . Z_m .... |
module type PVSS = sig module type ENCODED = sig type t include S . B58_DATA with type t := t include S . ENCODER with type t := t end module Commitment : ENCODED module Encrypted_share : ENCODED module Clear_share : ENCODED module Public_key : sig type t val pp : Format . formatter -> t -> unit include Compare . S wit... |
module MakePvss ( G : CYCLIC_GROUP ) : PVSS = struct module type ENCODED = sig type t include S . B58_DATA with type t := t include S . ENCODER with type t := t end module Dleq = MakeDleq ( G ) type proof = Dleq . proof module PZ_m = PZ_q ( G . Z_m ) module Public_key = G module Secret_key = struct include G . Z_m let ... |
module G : Pvss . CYCLIC_GROUP = struct module Z_m = struct include Group . Scalar let n = Group . order let ( + ) = Group . Scalar . add let ( * ) = Group . Scalar . mul let ( - ) = Group . Scalar . sub let ( = ) = Group . Scalar . equal let inv = Group . Scalar . inverse end include Group let name = " secp256k1 " let... |
let convert_encoding de1 de2 x = Data_encoding . Binary . of_bytes_exn de2 ( Data_encoding . Binary . to_bytes_exn de1 x ) |
let generate_keys ( ? seed = Hacl . Rand . gen 32 ) ( ) = let s = Secp256k1_group . Group . Scalar . of_bits_exn ( Bigstring . of_bytes seed |> Bigstring . to_string ) in let sk = convert_encoding Secp256k1_group . Group . Scalar . encoding Secret_key . encoding s in let pk = Secret_key . to_public_key sk in ( pk , sk ... |
type count_matrix = int array array |
type background = float array |
type t = float array array |
let int_of_char = function | ' a ' | ' A ' -> 0 | ' c ' | ' C ' -> 1 | ' g ' | ' G ' -> 2 | ' t ' | ' T ' -> 3 | _ -> 4 |
let flat_background ( ) = Caml . Array . make 4 0 . 25 |
let background_of_sequence seq pc = let counts = Caml . Array . make 4 0 and n = ref 0 in for i = 0 to String . length seq - 1 do let k = int_of_char seq [ . i ] i in if k < 4 then ( counts ( . k ) k <- counts ( . k ) k + 1 ; incr n ) done ; Array . map ~ f ( : fun c -> ( float c . + pc ) pc . / ( float ! n . + 4 . . *... |
let reverse_complement a = let open Array in let n = length a in init n ~ f ( : fun i -> let r = copy a ( . n - 1 - i ) i in swap r 0 3 ; swap r 1 2 ; r ) |
let make mat bg = let open Array in map mat ~ f ( : fun p -> let n = fold ~ f ( : + ) ~ init : 0 p in let r = mapi p ~ f ( : fun i x -> log ( ( float x . + bg ( . i ) i ) i . / float n . / bg ( . i ) i ) i ) in let n_case = Stream . Infix ( . 0 --^ ( Array . length p ) p ) p |> Stream . fold ~ f ( : fun accu i -> accu ... |
let tandem ( ? orientation = ` direct ) direct ~ spacer mat1 mat2 bg = Array . concat [ ( if Poly ( . orientation = ` everted ) everted then reverse_complement else Fun . id ) id ( make mat1 bg ) bg ; Array . init spacer ~ f ( : fun _ -> Caml . Array . make 5 0 ) . ; ( if Poly ( . orientation = ` inverted ) inverted th... |
let gen_scan f init mat seq tol = let r = ref init and n = String . length seq and m = Array . length mat in let seq = Array . init n ~ f ( : fun i -> int_of_char seq [ . i ] i ) i in for i = n - m downto 0 do let score = ref 0 . in for j = 0 to m - 1 do score := ! score . + Array ( . unsafe_get ( unsafe_get mat j ) j ... |
let scan = gen_scan ( fun pos score l -> ( pos , score ) score :: l ) l [ ] |
let best_hit mat seq = let ( pos , _ ) _ as r = gen_scan ( fun p1 s1 ( ( _ , s2 ) s2 as r2 ) r2 -> if Float ( . s1 > s2 ) s2 then ( p1 , s1 ) s1 else r2 ) r2 ( - 1 , Float . neg_infinity ) neg_infinity mat seq Float . neg_infinity in if pos < 0 then raise ( Invalid_argument " Pwm . best_hit : sequence shorter than the ... |
let fast_scan mat seq tol = let n = String . length seq in let seq = Array . init n ~ f ( : fun i -> int_of_char seq [ . i ] i ) i in stub_fast_scan mat seq tol |
type input = Pytypes . input = Single | File | Eval |
let string_of_input input = match input with | File -> " exec " | Eval -> " eval " | Single -> " single " |
type ' a file = ' a Pytypes . file = Filename of string | Channel of ' a |
type compare = Pytypes . compare = LT | LE | EQ | NE | GT | GE |
type ucs = UCSNone | UCS2 | UCS4 |
type closure = WithoutKeywords of ( pyobject -> pyobject ) pyobject | WithKeywords of ( pyobject -> pyobject -> pyobject ) pyobject = " pyml_wrap_closure " = " PyObject_CallFunctionObjArgs_wrapper " -> pyobject = " PyObject_CallMethodObjArgs_wrapper " = " PyErr_Fetch_wrapper " = " PyErr_Restore_wrapper " = " PyString_A... |
let ( ) = ignore ( UCSNone , UCS2 , UCS4 ) UCS4 |
let initialized = ref false |
let is_initialized ( ) = ! initialized |
let assert_initialized ( ) = if not ! initialized then failwith " Py . assert_initialized : run ' Py . initialize ( ) ' first " |
let version_value = ref " " |
let version_major_value = ref 0 |
let version_minor_value = ref 0 |
let program_name = ref Sys . argv ( . 0 ) 0 |
let set_program_name s = program_name := s ; if ! initialized then if ! version_major_value <= 2 then Pywrappers . Python2 . py_setprogramname s else Pywrappers . Python3 . py_setprogramname s |
let python_home = ref None |
let pythonpaths = ref [ ] |
let set_python_home s = python_home := ( Some s ) s ; if ! initialized then if ! version_major_value <= 2 then Pywrappers . Python2 . py_setpythonhome s else Pywrappers . Python3 . py_setpythonhome s |
let add_python_path path = pythonpaths := path :: ! pythonpaths |
let extract_version version_line = let before = try String . index version_line ' ' with Not_found -> let msg = Printf . sprintf " Py . extract_version : cannot parse the version line ' % s ' " version_line in failwith msg in Pyutils . split_left_on_char ~ from ( : succ before ) before ' ' version_line |
let extract_version_major_minor version = try if String . length version >= 3 && version [ . 1 ] 1 = ' . ' then let major = int_of_string ( String . sub version 0 1 ) 1 in let minor = if String . length version = 3 || version [ . 3 ] 3 = ' . ' then int_of_string ( String . sub version 2 1 ) 1 else if String . length ve... |
let run_command ( ? input = ) " " command read_stderr = let ( input_channel , output , error ) error = Unix . open_process_full command ( Unix . environment ( ) ) in let result = try output_string output input ; close_out output ; Pyutils . input_lines ( if read_stderr then error else input_channel ) input_channel with... |
let run_command_opt ? input command read_stderr = try Some ( run_command ? input command read_stderr ) read_stderr with Failure _ -> None |
let parent_dir filename = let dirname = Filename . dirname filename in Filename . concat dirname Filename . parent_dir_name |
let has_putenv = ref false |
let has_set_pythonpath = ref None |
let init_pythonhome verbose pythonhome = pythonhome <> " " && try ignore ( Sys . getenv " PYTHONHOME ) " ; false with Not_found -> if verbose then begin Printf . eprintf " Temporary set PYTHONHOME " =\% s " . \\ n " pythonhome ; flush stderr ; end ; Unix . putenv " PYTHONHOME " pythonhome ; has_putenv := true ; true |
let uninit_pythonhome ( ) = if ! has_putenv then begin unsetenv " PYTHONHOME " ; has_putenv := false end |
let uninit_pythonpath ( ) = match ! has_set_pythonpath with None -> ( ) | Some old_pythonpath -> begin has_set_pythonpath := None ; match old_pythonpath with None -> unsetenv " PYTHONPATH " | Some old_pythonpath ' -> Unix . putenv " PYTHONPATH " old_pythonpath ' end |
let ldd executable = let command = Printf . sprintf " ldd % s " executable in match run_command_opt command false with None -> [ ] | Some lines -> let extract_line line = String . trim ( Pyutils . split_left_on_char ' ( ' ' ( Pyutils . split_right_on_char ' > ' line ) line ) line in List . map extract_line lines |
let ldconfig ( ) = match run_command_opt " ldconfig - p " false with None -> [ ] | Some lines -> let extract_line line = String . trim ( Pyutils . split_right_on_char ' > ' line ) line in List . map extract_line lines |
let libpython_from_interpreter python_full_path = let lines = ldd python_full_path in let is_libpython line = let basename = Filename . basename line in Stdcompat . String . starts_with ~ prefix " : libpython " basename in List . find_opt is_libpython lines |
let libpython_from_ldconfig major minor = let lines = ldconfig ( ) in let prefix = match major , minor with None , _ -> " libpython " | Some major ' , None -> Printf . sprintf " libpython % d " major ' | Some major ' , Some minor ' -> Printf . sprintf " libpython % d . % d " major ' minor ' in let is_libpython line = l... |
let parse_python_list list = let length = String . length list in let buffer = Buffer . create 17 in let rec parse_item accu index = if index < length then match list [ . index ] index with ' \ ' ' -> begin let item = Buffer . contents buffer in let accu = item :: accu in if index + 1 < length then match list [ . index... |
let pythonpaths_from_interpreter python_full_path = let command = " \ print ( printsys . path ) path match try run_command ~ input : command python_full_path false with Failure _ -> [ ] with [ path_line ] path_line -> begin match parse_python_list path_line with None -> [ ] | Some paths -> paths end | _ -> [ ] |
let concat_library_filenames library_paths library_filenames = let expand_filepaths filename = filename :: List . map ( fun path -> Filename . concat path filename ) filename library_paths in List . concat ( List . map expand_filepaths library_filenames ) library_filenames |
let library_suffix = match Pyml_arch . os with | Pyml_arch . Mac -> " . dylib " | _ -> " . so " |
let libpython_from_pkg_config version_major version_minor = let command = Printf . sprintf " pkg - config -- libs python -% d . % d " version_major version_minor in match run_command_opt command false with Some ( words :: _ ) _ -> let word_list = String . split_on_char ' ' words in let unable_to_parse ( ) = let msg = P... |
let library_patterns : ( int -> int -> string ) string list = match Pyml_arch . os with | Pyml_arch . Windows -> [ Printf . sprintf " python % d % dm . dll " ; Printf . sprintf " python % d % d . dll ] " | Pyml_arch . Mac -> [ Printf . sprintf " libpython % d . % dm . dylib " ; Printf . sprintf " libpython % d . % d . ... |
let libpython_from_python_config version_major version_minor = let command = Printf . sprintf " python % d . % d - config -- ldflags " version_major version_minor in match run_command_opt command false with | Some ( words :: _ ) _ -> let word_list = String . split_on_char ' ' words in let parse_word library_paths word ... |
let libpython_from_pythonhome version_major version_minor python_full_path = let library_paths = match try Some ( Sys . getenv " PYTHONHOME ) " with Not_found -> match python_full_path with None -> None | Some python_full_path -> Some ( parent_dir python_full_path ) python_full_path with None -> failwith " Unable to fi... |
let find_library_path version_major version_minor python_full_path = let heuristics = [ ( fun ( ) -> Option . bind python_full_path ( fun path -> Option . map ( fun path -> [ path ] path ) path ( libpython_from_interpreter path ) path ) path ) path ; ( fun ( ) -> Option . map ( fun path -> [ path ] path ) path ( libpyt... |
let python_version_from_interpreter interpreter = let version_line = let python_version_cmd = Printf . sprintf " " \% s " \ -- version " interpreter in try List . hd ( run_command python_version_cmd false ) false with Failure _ -> List . hd ( run_command python_version_cmd true ) true in extract_version version_line |
let library_filename = ref None |
let load_library filename = library_filename := filename ; load_library filename None |
let get_library_filename ( ) = ! library_filename |
let find_library ~ verbose ~ version_major ~ version_minor ~ debug_build python_full_path = try load_library None with Failure _ -> let library_filenames = find_library_path version_major version_minor python_full_path in let errors = Buffer . create 17 in let rec try_load_library library_filenames = match library_file... |
let initialize_library ~ verbose ~ version_major ~ version_minor ~ debug_build python_full_path = begin match ! python_home with None -> ( ) | Some s -> ignore ( init_pythonhome verbose s ) s end ; find_library ~ verbose ~ version_major ~ version_minor ~ debug_build python_full_path ; set_program_name ! program_name ; ... |
let which_command = match Pyml_arch . os with | Pyml_arch . Windows -> " where " | _ -> " command - v " |
let which program = let exe = match Pyml_arch . os with | Pyml_arch . Windows -> if Filename . check_suffix program " . exe " then program else program ^ " . exe " | _ -> program in let command = Printf . sprintf " % s " \% s " " \ which_command exe in match run_command_opt command false with Some ( path :: _ ) _ -> So... |
let find_interpreter interpreter version minor = match interpreter with Some interpreter ' -> if String . contains interpreter ' ' / ' then Some interpreter ' else which interpreter ' | None -> match Option . bind version ( fun version ' -> match Option . bind minor ( fun minor ' -> which ( Printf . sprintf " python % ... |
let version_mismatch interpreter found expected = Printf . sprintf " Version mismatch : % s is version % s but version % s is expected " interpreter found expected |
let build_version_string major minor = Printf . sprintf " % d . % d " major minor |
let path_separator = match Pyml_arch . os with | Pyml_arch . Windows -> " ; " | _ -> " " : |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.