text stringlengths 0 601k |
|---|
let num_continuation_uses t cont = match Continuation . Map . find cont t . continuation_uses with | exception Not_found -> 0 | uses -> Continuation_uses . number_of_uses uses |
let all_continuations_used t = Continuation . Map . keys t . continuation_uses |
let union t1 t2 = let continuation_uses = Continuation . Map . union ( fun _ uses1 uses2 -> Some ( Continuation_uses . union uses1 uses2 ) ) t1 . continuation_uses t2 . continuation_uses in { continuation_uses } |
let remove t cont = { continuation_uses = Continuation . Map . remove cont t . continuation_uses } |
type state = { force_squared_check : bool ; spinner1_val : int ; mutable spinner_edit_mode : bool ; value_box_val : int ; mutable value_box_edit_mode : bool ; text_box_text : string ; mutable text_box_edit_mode : bool ; show_text_input_box : bool ; text_input_text : string ; combo_box_active : int ; dropdown1_active : ... |
let setup ( ) = Raylib . init_window width height " raygui - controls test suite " ; Raylib . set_target_fps 60 ; { force_squared_check = false ; spinner1_val = 0 ; spinner_edit_mode = false ; value_box_edit_mode = false ; value_box_val = 50 ; text_box_text = " Text box " ; text_box_edit_mode = false ; show_text_input_... |
let rec loop s = match Raylib . window_should_close ( ) with | true -> Raylib . close_window ( ) | false -> let open Raylib in let col = Raygui . ( get_style ( Control . Default ` Background_color ) ) |> get_color in begin_drawing ( ) ; clear_background col ; if s . show_text_input_box then Raygui . lock ( ) ; let rect... |
let ( ) = setup ( ) |> loop |
let convert_unsafety is_unsafe : Clambda_primitives . is_safe = if is_unsafe then Unsafe else Safe |
let convert ( prim : Lambda . primitive ) : Clambda_primitives . primitive = match prim with | Pmakeblock ( tag , mutability , shape , mode ) -> Pmakeblock ( tag , mutability , shape , mode ) | Pmakefloatblock ( mutability , mode ) -> Pmakearray ( Pfloatarray , mutability , mode ) | Pfield ( field , _ ) -> Pfield field... |
let setup ( ) = let open Raylib in set_config_flags [ ConfigFlags . Window_resizable ] ; init_window width height " raylib [ core ] example - 2d camera " ; let player = Rectangle . create 400 . 0 280 . 0 40 . 0 40 . 0 in let spacing = ref 0 in let buildings = Array . init 100 ( fun _ -> let bheight = get_random_value 1... |
let rec loop ( player , buildings , colors , camera ) = match Raylib . window_should_close ( ) with | true -> Raylib . close_window ( ) | false -> let open Raylib in ( if is_key_down Key . Right then Rectangle . ( set_x player ( x player . + 2 . 0 ) ) else if is_key_down Key . Left then Rectangle . ( set_x player ( x p... |
let ( ) = setup ( ) |> loop |
type player_t = { position : Raylib . Vector2 . t ; speed : float ; can_jump : bool } |
type env_item_t = { box : Raylib . Rectangle . t ; blocking : bool ; color : Raylib . Color . t ; } |
type camera_mode_t = | Center | CenterInsideMap | SmoothFollow | EvenOutOnLanding of bool * float | PlayerBoundsPush |
type state_t = player_t * env_item_t List . t * Raylib . Camera2D . t * camera_mode_t |
let half_screen = Raylib . Vector2 . create ( Float . of_int width . / 2 . ) ( Float . of_int height . / 2 . ) |
let bbox_x , bbox_y = ( 0 . 2 , 0 . 2 ) |
type comparision_t = Higher | Lower | Equal |
let compare tol a b = if Float . abs ( a . - b ) < tol then Equal else if a > b then Higher else Lower |
let player_rec player = let open Raylib in let x , y , w , h = Vector2 . ( x player . position . - 20 . , y player . position . - 40 . , 40 . , 40 . ) in Rectangle . create x y w h |
let camera_description = function | Center -> " Follow player center " | CenterInsideMap -> " Follow player center , but clamp to map edges " | SmoothFollow -> " Follow player center ; smoothed " | EvenOutOnLanding _ -> " Follow player center horizontally ; update player center vertically \ after landing " | PlayerBoun... |
let clamp_zoom z = if z > 3 . 0 then 3 . 0 else if z < 0 . 25 then 0 . 25 else z |
let vy_of_float y = Raylib . Vector2 . create 0 . 0 y |
let setup ( ) = let open Raylib in set_config_flags [ ConfigFlags . Window_resizable ] ; init_window width height " raylib [ core ] example - 2d camera " ; let player = { position = half_screen ; speed = 0 . 0 ; can_jump = false } in let env_items = [ { box = Rectangle . create 0 . 0 0 . 0 1000 . 0 500 . 0 ; blocking =... |
let update_player delta ( { position ; speed ; can_jump } , env_items , c , m ) = let open Raylib in let x , y = Vector2 . ( x position , y position ) in let x = match ( is_key_down Key . Left , is_key_down Key . Right ) with | true , false -> x . - ( player_hor_speed . * delta ) | false , true -> x . + ( player_hor_sp... |
let update_camera delta ( player , env_items , camera , mode ) = let open Raylib in let mode = if is_key_pressed Key . C then match mode with | Center -> CenterInsideMap | CenterInsideMap -> SmoothFollow | SmoothFollow -> EvenOutOnLanding ( false , 0 . 0 ) | EvenOutOnLanding _ -> PlayerBoundsPush | PlayerBoundsPush -> ... |
let draw_all ( player , env_items , camera , mode ) = let open Raylib in begin_drawing ( ) ; clear_background Color . raywhite ; begin_mode_2d camera ; List . iter ( fun item -> draw_rectangle_rec item . box item . color ) env_items ; draw_rectangle_rec ( player_rec player ) Color . red ; end_mode_2d ( ) ; draw_text " ... |
let rec loop state = let delta = Raylib . get_frame_time ( ) in match Raylib . window_should_close ( ) with | true -> Raylib . close_window ( ) | false -> state |> update_player delta |> update_camera delta |> draw_all |> loop |
let ( ) = setup ( ) |> loop |
type column_t = { height : float ; position : Raylib . Vector3 . t ; color : Raylib . Color . t ; } |
let setup ( ) = let open Raylib in init_window width height " raylib [ core ] example - 3d camera first person " ; let camera = Camera . create ( Vector3 . create 4 . 0 2 . 0 4 . 0 ) ( Vector3 . create 0 . 0 1 . 8 0 . 0 ) ( Vector3 . create 0 . 0 1 . 0 0 . 0 ) 60 . 0 CameraProjection . Perspective in let columns = List... |
let draw_all camera columns = let open Raylib in begin_drawing ( ) ; clear_background Color . raywhite ; begin_mode_3d camera ; draw_plane ( Vector3 . create 0 . 0 0 . 0 0 . 0 ) ( Vector2 . create 32 . 0 32 . 0 ) Color . lightgray ; draw_cube ( Vector3 . create . ~- 16 . 0 2 . 5 0 . 0 ) 1 . 0 5 . 0 32 . 0 Color . blue ... |
let rec loop ( camera , columns ) = let open Raylib in if window_should_close ( ) then close_window ( ) else update_camera ( addr camera ) ; draw_all camera columns ; loop ( camera , columns ) |
let ( ) = setup ( ) |> loop |
type column_t = { height : float ; position : Raylib . Vector3 . t ; color : Raylib . Color . t ; } |
let cube_pos = Raylib . Vector3 . create 0 . 0 0 . 0 0 . 0 |
let setup ( ) = let open Raylib in init_window width height " raylib [ core ] example - 3d camera free " ; let camera = Camera . create ( Vector3 . create 10 . 0 10 . 0 10 . 0 ) ( Vector3 . create 0 . 0 0 . 0 0 . 0 ) ( Vector3 . create 0 . 0 1 . 0 0 . 0 ) 45 . 0 CameraProjection . Perspective in set_camera_mode camera ... |
let draw_all camera = let open Raylib in begin_drawing ( ) ; clear_background Color . raywhite ; begin_mode_3d camera ; draw_cube cube_pos 2 . 0 2 . 0 2 . 0 Color . red ; draw_cube_wires cube_pos 2 . 0 2 . 0 2 . 0 Color . maroon ; draw_grid 10 1 . 0 ; end_mode_3d ( ) ; draw_rectangle 10 10 320 133 ( fade Color . skyblu... |
let rec loop camera = let open Raylib in if window_should_close ( ) then close_window ( ) else let camera = if is_key_down Key . Z then Camera . ( create ( position camera ) ( Vector3 . create 0 . 0 0 . 0 0 . 0 ) ( up camera ) 45 . 0 CameraProjection . Perspective ) else camera in update_camera ( addr camera ) ; draw_a... |
let ( ) = setup ( ) |> loop |
type column_t = { height : float ; position : Raylib . Vector3 . t ; color : Raylib . Color . t ; } |
let cube_pos = Raylib . Vector3 . create 0 . 0 1 . 0 0 . 0 |
let setup ( ) = let open Raylib in init_window width height " raylib [ core ] example - 3d camera mode " ; let camera = Camera . create ( Vector3 . create 10 . 0 10 . 0 10 . 0 ) ( Vector3 . create 0 . 0 0 . 0 0 . 0 ) ( Vector3 . create 0 . 0 1 . 0 0 . 0 ) 45 . 0 CameraProjection . Perspective in set_camera_mode camera ... |
let draw_all camera collision ray = let open Raylib in begin_drawing ( ) ; clear_background Color . raywhite ; begin_mode_3d camera ; if collision then ( draw_cube cube_pos 2 . 0 2 . 0 2 . 0 Color . red ; draw_cube_wires cube_pos 2 . 0 2 . 0 2 . 0 Color . maroon ; draw_cube_wires cube_pos 2 . 2 2 . 2 2 . 2 Color . gree... |
let rec loop camera collision ray = let open Raylib in if window_should_close ( ) then close_window ( ) else ( update_camera ( addr camera ) ; let collision , ray = match ( is_mouse_button_pressed MouseButton . Left , collision ) with | true , true -> ( false , None ) | true , false -> let r = get_mouse_ray ( get_mouse... |
let ( ) = let camera = setup ( ) in loop camera false None |
type state_t = Waiting | Loading of int | Finished |
let setup ( ) = Raylib . init_window 800 450 " raylib [ core ] example - loading thread " ; Raylib . set_target_fps 60 |
let data_progress = ref 0 |
let load_data_thread ( ) = let rec loop prev_time = let time = Raylib . get_time ( ) in data_progress := ! data_progress + Int . of_float ( 50 . 0 . * ( time . - prev_time ) ) ; Thread . delay 0 . 05 ; loop time in loop ( Raylib . get_time ( ) ) |
let rec loop state = match Raylib . window_should_close ( ) with | true -> Raylib . close_window ( ) | false -> let open Raylib in let state = match state with | Waiting -> if is_key_pressed Key . Enter then ( ignore ( Thread . create load_data_thread ( ) ) ; Loading 0 ) else Waiting | Loading frames_counter -> if ! da... |
let ( ) = setup ( ) ; loop Waiting |
let setup ( ) = let open Raylib in set_config_flags [ ConfigFlags . Msaa_4x_hint ] ; init_window width height " raylib [ core ] example - vr simulator " ; let hmd = VrDeviceInfo . create ( ) in VrDeviceInfo . ( set_h_resolution hmd 2160 ; set_v_resolution hmd 1200 ; set_h_screen_size hmd 0 . 133793 ; set_v_screen_size ... |
let rec loop ( distortion , cube_position , camera , config , target ) = match Raylib . window_should_close ( ) with | true -> let open Raylib in unload_shader distortion ; unload_vr_stereo_config config ; close_window ( ) | false -> let open Raylib in update_camera ( addr camera ) ; begin_texture_mode target ; clear_b... |
let ( ) = setup ( ) |> loop |
let clamp_value ( x , y ) ( mi_x , mi_y ) ( ma_x , ma_y ) = Float . ( max mi_x ( min ma_x x ) , max mi_y ( min ma_y y ) ) |
let origin = Raylib . Vector2 . create 0 . 0 0 . 0 |
let init_colors ( ) = let open Raylib in Array . init 10 ( fun _ -> Color . create ( get_random_value 100 250 ) ( get_random_value 50 150 ) ( get_random_value 10 100 ) 255 ) |
let setup ( ) = let open Raylib in set_config_flags [ ConfigFlags . Window_resizable ; ConfigFlags . Vsync_hint ] ; init_window 800 450 " raylib [ core ] example - window scale letterbox " ; set_window_min_size 320 240 ; let target = load_render_texture ( Int . of_float game_width ) ( Int . of_float game_height ) in se... |
let draw ( target , colors ) = let open Raylib in let sx , sy = ( Float . of_int ( get_screen_width ( ) ) , Float . of_int ( get_screen_height ( ) ) ) in let scale = Float . min ( sx . / game_width ) ( sy . / game_height ) in let mouse_x , mouse_y = let mouse = get_mouse_position ( ) in Vector2 . ( x mouse , y mouse ) ... |
let update ( target , colors ) = let open Raylib in let colors = if is_key_pressed Key . Space then init_colors ( ) else colors in ( target , colors ) |
let rec loop ( target , colors ) = match Raylib . window_should_close ( ) with | true -> Raylib . unload_render_texture target ; Raylib . close_window ( ) | false -> ( target , colors ) |> draw |> update |> loop |
let ( ) = setup ( ) |> loop |
type t = { size : Code_size . t ; removed : Removed_operations . t } |
type code_characteristics = { cost_metrics : t ; params_arity : int } |
let zero = { size = Code_size . zero ; removed = Removed_operations . zero } |
let size t = t . size |
let removed t = t . removed |
let print ppf t = Format . fprintf ppf " [ @< hov 1 > size : % a removed : { % a } ] " @ Code_size . print t . size Removed_operations . print t . removed |
let from_size size = { size ; removed = Removed_operations . zero } |
let notify_added ~ code_size t = { t with size = Code_size . ( + ) t . size code_size } |
let notify_removed ~ operation t = { t with removed = Removed_operations . ( + ) t . removed operation } |
let ( + ) a b = { size = Code_size . ( + ) a . size b . size ; removed = Removed_operations . ( + ) a . removed b . removed } |
let set_of_closures ~ find_code_characteristics set_of_closures = let func_decls = Set_of_closures . function_decls set_of_closures in let funs = Function_declarations . funs func_decls in let num_clos_vars = Set_of_closures . value_slots set_of_closures |> Value_slot . Map . cardinal in let cost_metrics , num_words = ... |
let increase_due_to_let_expr ~ is_phantom ~ cost_metrics_of_defining_expr = if is_phantom then zero else cost_metrics_of_defining_expr |
let increase_due_to_let_cont_non_recursive ~ cost_metrics_of_handler = cost_metrics_of_handler |
let increase_due_to_let_cont_recursive ~ cost_metrics_of_handlers = cost_metrics_of_handlers |
let evaluate ~ args ( t : t ) = Code_size . evaluate ~ args t . size . - Removed_operations . evaluate ~ args t . removed |
let equal { size = size1 ; removed = removed1 } { size = size2 ; removed = removed2 } = Code_size . equal size1 size2 && Removed_operations . equal removed1 removed2 |
module Model = struct type t = { counters : int Int . Map . t } [ @@ deriving sexp , fields , equal ] let add_new t = let map_len = Map . length t . counters in print_s [ % message ( map_len : int ) ] ; if map_len >= maximum_data_points then t else { counters = Map . set t . counters ~ key : map_len ~ data : 1 } ; ; le... |
module Action = struct type t = | New_counter | Update of { pos : int ; diff : int } [ @@ deriving sexp ] let should_log _ = true end |
module State = struct type t = unit end |
let apply_action model action _ ~ schedule_action : _ = match ( action : Action . t ) with | New_counter -> Model . add_new model | Update { pos ; diff } -> Model . update model ~ pos ~ diff ; ; |
let on_startup ~ schedule_action : _ _ = Async_kernel . return ( ) |
let view ( m : Model . t ) ( ~ inject : Action . t -> unit Vdom . Effect . t ) = let open Vdom in let on_add_new_click = Attr . on_click ( fun _ev -> inject New_counter ) in let add_new_counter_button = Node . div [ Node . button ~ attr : on_add_new_click [ Node . text " add new counter " ] ] in let button txt ~ pos ~ ... |
let create model ~ old_model : _ ~ inject = let open Incr . Let_syntax in let % map model = model in let apply_action = apply_action model in let view = view model ~ inject in Component . create ~ apply_action model view ; ; |
module Make ( Bits : sig val bits : int end ) = struct open Hardcaml . Signal module I = struct type ' a t = { data : ' a [ @ bits Bits . bits ] } [ @@ deriving sexp_of , hardcaml ] end module O = struct type ' a t = { count : ' a [ @ bits Int . ceil_log2 Bits . bits ] } [ @@ deriving sexp_of , hardcaml ] end let creat... |
let command = Async . Command . async ~ summary " : count leading zeros logic " ( let open Command . Let_syntax in let % map_open ( ) = return ( ) and flags = Hardcaml_xilinx_reports . Command . Command_flags . flags and bits = flag " bits " ( required int ) ~ doc " : BITS Number of input bits " in fun ( ) -> let modul... |
let ref = ( 3 [ @ manual . ref " ch : pentatonic " ] ) ] } and that their values are consistent with the computed references for the payload labels ( e . g " sec : major " , " ch : pentatonic " ) present in the TeX auxiliary file [ tex . aux ] ) * |
type error = | Reference_mismatch of { loc : Location . t ; label : string ; ocaml : int list ; tex : int list } | Unknown_label of Location . t * string | Tuple_expected of Location . t | No_aux_file | Wrong_attribute_payload of Location . t |
let pp_ref ppf = Format . pp_print_list ~ pp_sep ( : fun ppf ( ) -> Format . pp_print_string ppf " . " ) Format . pp_print_int ppf |
let print_error error = Location . print_report Format . std_formatter @@ match error with | Tuple_expected loc -> Location . errorf ~ loc " Integer tuple expected after manual reference annotation . " @ | Unknown_label ( loc , label ) -> Location . errorf ~ loc " [ @< hov > Unknown manual label :@ % s ] . " @@ label |... |
type tex_reference = { label : string ; pos : int list ; level : string } |
type status = Ok | Bad | Unknown |
type ml_reference = { loc : Location . t ; pos : int list ; status : status } |
let check_consistency ( ref : tex_reference ) { loc ; pos ; _ } = if ref . pos = pos then { loc ; pos ; status = Ok } else begin print_error @@ Reference_mismatch { loc ; label = ref . label ; tex = ref . pos ; ocaml = pos } ; { loc ; pos ; status = Bad } end |
let rec check_final_status label error = function | { status = Ok ; _ } -> error | { status = Bad ; _ } -> true | { status = Unknown ; loc ; _ } -> print_error ( Unknown_label ( loc , label ) ) ; true |
module TeX = struct let scan s = try Scanf . sscanf s " \\ newlabel { % s } { { @% s } { @% _d } { % _s } { @% s . @% _s } { @% _s } } " @ ( fun label position_string level -> let pos = List . map int_of_string ( String . split_on_char ' . ' position_string ) in Some { label ; level ; pos } ) with | Scanf . Scan_failur... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.