text stringlengths 0 601k |
|---|
let find_path (g: 'a graph) (a: 'a) (b: 'a) : ('a list * weight) = let rec aux_node (node: 'a * weight) (visited : 'a list) : ('a list * weight) = let (v2, w) = node in let list_of_neighbours = neighbours g v2 in if v2 = b then ([b], w) else if List.mem v2 visited then raise Fail else if list_of_neighbours = [] then ra... |
let find_path' (g: 'a graph) (a: 'a) (b: 'a) : ('a list * weight) = let rec aux_node (node: 'a * weight) (visited : 'a list) fc sc : ('a list * weight)= let (v2, w) = node in let list_of_neighbours = neighbours g v2 in if v2 = b then sc([b], w) else if not(List.mem v2 visited) then let acc = visited @ [v2] in let sc_fu... |
let find_longest_path (g: 'a graph) (a: 'a) (b: 'a) : ('a list * weight) option = let rec longest l = match l with | [] -> None | [(v2, w)] -> Some (v2, w) | a_list -> let f = fun a b -> let (v1, w1) = a in let (v2, w2) = b in if w1 < w2 then 1 else if w1 = w2 then 0 else -1 in let l = List.sort f a_list in Some (List.... |
let open_account (initial_pass: passwd) : bank_account = let balance = ref 0 in let password = ref initial_pass in let errors = ref 0 in { update_pass = (fun (old_pass : passwd) -> fun (new_pass : passwd) -> if old_pass = !password then password := new_pass else (errors := !errors + 1; raise wrong_pass)); retrieve = (f... |
let neighbours (g: 'a graph) (vertex: 'a) : ('a * weight) list = List.fold_left (fun acc (edge : ('a * 'a * weight)) -> let (a, b, w) = edge in if (a = vertex) then ((b,w)::acc) else acc) [] g.edges ;; |
let find_path (g: 'a graph) (a: 'a) (b: 'a) : ('a list * weight) = let rec aux_node (node: 'a * weight) (visited : 'a list) : ('a list * weight) = if List.exists (fun n -> let (content, weight) = node in n = content) visited then raise Fail else let (content, weight) = node in if content = b then ([content], weight) el... |
let find_path' (g: 'a graph) (a: 'a) (b: 'a) : ('a list * weight) = let rec aux_node (node: 'a * weight) (visited : 'a list) fc sc : ('a list * weight)= notimplemented() in notimplemented() let helper_find_path (g: 'a graph) (a: 'a) (b: 'a) : ('a list * weight) = let rec aux_node (node: 'a * weight) (visited : 'a list)... |
let find_longest_path (g: 'a graph) (a: 'a) (b: 'a) : ('a list * weight) option = let rec longest paths path = match paths with | [] -> if (snd path) <= (-60) then None else Some path | h::t -> let (newpath, newweight) = h in if (newweight) > (snd path) then (longest (t) (h)) else longest t path in longest (find_all_pa... |
let open_account (initial_pass: passwd) : bank_account = let pass = ref initial_pass in let balance = ref 0 in let attempts = ref 0 in let check = (fun (in_pass: passwd) -> ( if (!attempts >= 5) then raise too_many_failures else if (in_pass = !pass) then let _ = (attempts := 0) in true else let _ = (attempts := !attemp... |
let neighbours (g: 'a graph) (vertex: 'a) : ('a * weight) list = List.map (fun (v1,v2,w) -> (v2,w)) (List.filter (fun (v1,v2,w) -> v1 = vertex) g.edges);; |
let find_path (g: 'a graph) (a: 'a) (b: 'a) : ('a list * weight) = let rec aux_node (node: 'a * weight) (visited : 'a list) : ('a list * weight) = let index = fst node in let w = snd node in if index = b then ([b], w) else if List.exists ((=) index) visited then raise Fail else let (path, nw) = aux_list (neighbours g i... |
let find_path' (g: 'a graph) (a: 'a) (b: 'a) : ('a list * weight) = let rec aux_node (node: 'a * weight) (visited : 'a list) fc sc : ('a list * weight)= let index = fst node in let w = snd node in if index = b then sc ([b], w) else if List.exists ((=) index) visited then fc() else aux_list (neighbours g index) (visited... |
let find_longest_path (g: 'a graph) (a: 'a) (b: 'a) : ('a list * weight) option = let all = find_all_paths g a b in match all with | [] -> None | _ -> Some (List.hd (List.sort (fun (path1: ('a list * weight)) (path2: ('a list * weight)) -> (snd path2) - (snd path1)) all));; |
let new_balance() : balances = let balance = ref 0 in { get_balance = (fun () -> !balance); set_balance = (:=) balance; };; let new_counter () : my_counter = let counter = ref 0 in { tick = (fun () -> counter := !counter + 1; !counter); reset = (fun() -> counter := 0); current_counter = (fun() -> !counter) };; let upda... |
let open_account (initial_pass: passwd) : bank_account = let count = new_counter() in let bal = new_balance() in let (password_var: password) = ref initial_pass in let new_account = {update_pass = update_pass (password_var) (count); retrieve = retrieve (count) (bal) (password_var); deposit = deposit (count) (bal) (pass... |
let neighbours (g: 'a graph) (vertex: 'a) : ('a * weight) list = let edge = g.edges in let rec aux (edge) (vertex: 'a) lts = match edge with | [] -> lts | x::xs -> if (getfirst x) = vertex then aux xs (vertex) (((getsecond x), (getthird x))::lts) else aux xs vertex lts in aux edge vertex [] ;; let getfirst2(a, _) = a;;... |
let find_path (g: 'a graph) (a: 'a) (b: 'a) : ('a list * weight) = let rec aux (g: 'a graph) (start) (b: 'a) (lts: 'a list) weights: ('a list * weight) = match lts with | [] -> raise Fail | x::_ -> if (x = b) then ((List.rev lts), weights) else match start with | [] -> raise Fail | hd::tl -> let h = hd in let t = tl in... |
let find_path' (g: 'a graph) (a: 'a) (b: 'a) : ('a list * weight) = let rec aux (g: 'a graph) (start) (b: 'a) (lts: 'a list) weights fail succeed: ('a list * weight) = match lts with | [] -> fail () | x::_ -> if (x = b) then succeed ((List.rev lts), weights) else match start with | [] -> fail () | hd::tl -> let h = hd ... |
let find_longest_path (g: 'a graph) (a: 'a) (b: 'a) : ('a list * weight) option = let paths = (find_all_paths g a b) in match paths with | [] -> None | _ -> let rec aux paths maxsize max = match paths with | [] -> Some maxsize | x::xs -> if (getsecond2 x) > max then (aux xs x (getsecond2 x)) else aux xs maxsize max in ... |
let new_balance() : balances = let balance = ref 0 in { get_balance = (fun () -> !balance); set_balance = (:=) balance; };; let new_counter () : my_counter = let counter = ref 0 in { tick = (fun () -> counter := !counter + 1; !counter); reset = (fun() -> counter := 0); current_counter = (fun() -> !counter) };; let upda... |
let open_account (initial_pass: passwd) : bank_account = let count = new_counter() in let bal = new_balance() in let (password_var: password) = ref initial_pass in let new_account = {update_pass = update_pass (password_var) (count); retrieve = retrieve (count) (bal) (password_var); deposit = deposit (count) (bal) (pass... |
let neighbours (g: 'a graph) (vertex: 'a) : ('a * weight) list = let edge = g.edges in let rec aux (edge) (vertex: 'a) lts = match edge with | [] -> lts | x::xs -> if (getfirst x) = vertex then aux xs (vertex) (((getsecond x), (getthird x))::lts) else aux xs vertex lts in aux edge vertex [] ;; let getfirst2(a, _) = a;;... |
let find_path (g: 'a graph) (a: 'a) (b: 'a) : ('a list * weight) = let rec aux (g: 'a graph) (start) (b: 'a) (lts: 'a list) weights: ('a list * weight) = match lts with | [] -> raise Fail | x::_ -> if (x = b) then ((List.rev lts), weights) else match start with | [] -> raise Fail | hd::tl -> let h = hd in let t = tl in... |
let find_path' (g: 'a graph) (a: 'a) (b: 'a) : ('a list * weight) = let rec aux (g: 'a graph) (start) (b: 'a) (lts: 'a list) weights fail succeed: ('a list * weight) = match lts with | [] -> fail () | x::_ -> if (x = b) then succeed ((List.rev lts), weights) else match start with | [] -> fail () | hd::tl -> let h = hd ... |
let find_longest_path (g: 'a graph) (a: 'a) (b: 'a) : ('a list * weight) option = let paths = (find_all_paths g a b) in match paths with | [] -> None | _ -> let rec aux paths maxsize max = match paths with | [] -> Some maxsize | x::xs -> if (getsecond2 x) > max then (aux xs x (getsecond2 x)) else aux xs maxsize max in ... |
let open_account (initial_pass: passwd) : bank_account = let password = ref initial_pass in let balance = ref 0 in let attempts = ref 0 in { update_pass = (fun (password_check: passwd) (new_password: passwd) -> if (!password = password_check) then (password := new_password; attempts := 0) else (attempts := !attempts + ... |
let neighbours (g: 'a graph) (vertex: 'a) : ('a * weight) list = List.fold_left(fun acc (s, d, w) -> if vertex = s then (d,w) :: acc else acc) [] g.edges;; |
let find_path (g: 'a graph) (a: 'a) (b: 'a) : ('a list * weight) = let rec aux_list (nodes: ('a * weight) list) (visited: 'a list) : ('a list * weight) = match nodes with | [] -> raise Fail | (x,wx)::xs -> if List.mem x visited then aux_list xs visited else if (x=b) then ([x], wx) else try aux_list xs (x::visited) with... |
let find_path' (g: 'a graph) (a: 'a) (b: 'a) : ('a list * weight) = let rec aux_list (nodes: ('a * weight) list) (visited: 'a list) fc sc : ('a list * weight) = match nodes with | [] -> fc (raise Fail) | (x,wx)::xs -> if List.mem x visited then fc (aux_list xs visited fc sc) else if (x=b) then sc ([x], wx) else try (au... |
let find_longest_path (g: 'a graph) (a: 'a) (b: 'a) : ('a list * weight) option = let rec findPath (longestPath: ('a list * weight)) (remainingPaths: (('a list * weight) list)) (longestPathLength: int) : ('a list * weight) = match remainingPaths with | [] -> longestPath | (s,w)::xs -> if ((List.length s) > longestPathL... |
let open_account (initial_pass: passwd) : bank_account = let password = ref initial_pass in let balance = ref 0 in let attempts = ref 0 in { update_pass = (fun (password_check: passwd) (new_password: passwd) -> if (!password = password_check) then (password := new_password; attempts := 0) else (attempts := !attempts + ... |
let neighbours (g: 'a graph) (vertex: 'a) : ('a * weight) list = List.fold_left(fun acc (s, d, w) -> if vertex = s then (d,w) :: acc else acc) [] g.edges;; |
let find_path (g: 'a graph) (a: 'a) (b: 'a) : ('a list * weight) = let rec aux_node (node: 'a * weight) (visited : 'a list) : ('a list * weight) = let (next, w) = node in if next = b then ([next], w) else if List.mem next visited then raise Fail else let (x, wx) = aux_list (neighbours g next) (next :: visited) in (next... |
let find_path' (g: 'a graph) (a: 'a) (b: 'a) : ('a list * weight) = let rec aux_node (node: 'a * weight) (visited : 'a list) fc sc : ('a list * weight)= let (next, w) = node in if next = b then sc ([next], w) else if List.mem next visited then fc () else let suc2 = fun (y, wx) -> sc (next::y, w+wx) in aux_list (neighbo... |
let find_longest_path (g: 'a graph) (a: 'a) (b: 'a) : ('a list * weight) option = let rec findPath (longestPath: ('a list * weight)) (remainingPaths: (('a list * weight) list)) (longestPathWeight: int) (longestPathLength: int) : ('a list * weight) = match remainingPaths with | [] -> longestPath | (s,w)::xs -> if (w > l... |
let open_account (initial_pass: passwd) : bank_account = let pass = ref initial_pass in let bal = ref 0 in let fail = ref 0 in { update_pass = ( fun p_old p_new -> if p_old = !pass then (fail := 0; pass := p_new) else if p_old != !pass then (fail := !fail+1; raise wrong_pass) ); deposit = ( fun p amt -> if !fail >= 5 t... |
let neighbours (g: 'a graph) (vertex: 'a) : ('a * weight) list = let rec f edges v n acc = if n < List.length edges then begin match List.nth edges n with | (v1, v2, w) when v1 = v -> f edges vertex (n+1) ((v2,w) :: acc) | (_,_,_) -> f edges vertex (n+1) acc end else acc in f g.edges vertex 0 [];; |
let find_path (g: 'a graph) (a: 'a) (b: 'a) : ('a list * weight) = let rec aux_node (node: 'a * weight) (visited : 'a list) : ('a list * weight) = if fst(node) = b then ([b],snd(node)) else if List.mem (fst(node)) visited then raise Fail else begin let result = aux_list (neighbours g (fst(node))) (fst(node)::visited) i... |
let find_path' (g: 'a graph) (a: 'a) (b: 'a) : ('a list * weight) = let rec aux_node (node: 'a * weight) (visited : 'a list) fc sc : ('a list * weight)= if fst(node) = b then (List.rev (fst(sc (b,snd(node)))), snd(sc (b,snd(node)))) else if List.mem (fst(node)) visited then fc () else begin let sc2 = sc (fst(node), snd... |
let find_longest_path (g: 'a graph) (a: 'a) (b: 'a) : ('a list * weight) option = let rec f paths p_max = match paths with | [] -> p_max | x :: xs -> let p = match p_max with | None -> 0 | Some s -> snd(s) in if snd(x) > p then f xs (Some x) else f xs p_max in let paths = find_all_paths g a b in f paths None;; |
let open_account (initial_pass: passwd) : bank_account = let password = ref initial_pass in let balance = ref 0 in let count = ref 0 in { update_pass = (fun curpass newpass -> (if curpass = !password then (password := (newpass); count := 0 ) else (count := !count + 1; raise wrong_pass))) ; retrieve = (fun pass amount -... |
let neighbours (g: 'a graph) (vertex: 'a) : ('a * weight) list = let get_first (a,_,_) = a in let get_out_vertex (_,b,c) = (b,c) in let rec loop acc l = match l with | [] -> acc | x::xs -> if (get_first x) = vertex then loop ((get_out_vertex x) :: acc) xs else loop acc xs in loop [] g.edges;; |
let find_path (g: 'a graph) (a: 'a) (b: 'a) : ('a list * weight) = let get_first (y,_) = y in let get_second(_,y) = y in let ans = [] in let rec aux_node (node: 'a * weight) (visited : 'a list) : ('a list * weight) = ([],0) and aux_list (nodes: ('a * weight) list) (visited: 'a list) : ('a list * weight) = ([],0) in not... |
let find_path' (g: 'a graph) (a: 'a) (b: 'a) : ('a list * weight) = let rec aux_node (node: 'a * weight) (visited : 'a list) fc sc : ('a list * weight)= notimplemented () and aux_list (nodes: ('a * weight) list) (visited: 'a list) fc sc : ('a list * weight) = notimplemented () in notimplemented ();; |
let find_longest_path (g: 'a graph) (a: 'a) (b: 'a) : ('a list * weight) option = notimplemented ();; |
let open_account (initial_pass: passwd) : bank_account = let bank_pass=ref initial_pass in let failed=ref 0 in let balance=ref 0 in { update_pass =(fun (p1: passwd) (newpass: passwd) -> if(!bank_pass = p1 ) then (failed:=0; bank_pass := newpass) else(failed := !failed+1; raise wrong_pass)); retrieve=(fun (p1: passwd) (... |
let neighbours (g: 'a graph) (vertex: 'a) : ('a * weight) list = List.fold_left (fun x (y1,y2,y3)->if y1=vertex then (y2,y3)::x else x) [] g.edges;; |
let find_path (g: 'a graph) (a: 'a) (b: 'a) : ('a list * weight) = let rec aux_node (node: 'a * weight) (visited : 'a list) (v : weight) : ('a list * weight) = let (a,c) = node in if a=b then (visited @ [a]),c+v else if List.mem a visited then raise Fail else aux_list (neighbours g a) ((visited @ [a])) (c+v) and aux_li... |
let find_path' (g: 'a graph) (a: 'a) (b: 'a) : ('a list * weight) = let rec aux_node (node: 'a * weight) (visited : 'a list) (v : weight) fc sc : ('a list * weight)= let (n1,w1) = node in if n1=b then let(path,v1) = sc() in (path@[n1],w1+v1) else if List.mem n1 visited then fc() else aux_list (neighbours g n1) (visited... |
let find_longest_path (g: 'a graph) (a: 'a) (b: 'a) : ('a list * weight) option = match find_all_paths g a b with |[]-> None |c->let rec find_max c acc t= match c with |[]-> Some t |w::d->let (_,h2) = w in if h2 > acc then find_max d h2 w else find_max d acc t in find_max c 0 ([],0);; |
let open_account (initial_pass: passwd) : bank_account = let password = ref initial_pass in let balance = ref 0 in let number = ref 5 in { update_pass = (fun old_pwd new_pwd -> (if (old_pwd <> !password) then begin number := !number - 1; raise wrong_pass; end else number := 5; password := new_pwd; ) ); retrieve = (fun ... |
let neighbours (g: 'a graph) (vertex: 'a) : ('a * weight) list = if g.edges = [] then failwith "invalid input" else let rec check_neigh neigh list_neights = match neigh with | [] -> list_neights | (orig,dest,weight) :: tl -> if orig = vertex then check_neigh tl list_neights@[(dest,weight)] else check_neigh tl list_neig... |
let find_path (g: 'a graph) (a: 'a) (b: 'a) : ('a list * weight) = let rec aux_node (node: 'a * weight) (visited : 'a list) : ('a list * weight) = let (path_noode,w) = node in if path_noode = b then ([path_noode],w) else let (path,cost) = aux_list (neighbours g path_noode) visited in if (List.length path) > 0 then (pat... |
let find_path' (g: 'a graph) (a: 'a) (b: 'a) : ('a list * weight) = let rec aux_node (node: 'a * weight) (visited : 'a list) fc sc : ('a list * weight)= let (path_noode,w) = node in if path_noode = b then sc ([path_noode],w) else let su2 = (fun (path,cost) -> if (List.length path) > 0 then sc (path_noode::path,cost+w) ... |
let find_longest_path (g: 'a graph) (a: 'a) (b: 'a) : ('a list * weight) option = let rec aux_node (node: 'a * weight) (visited : 'a list) : ('a list * weight) = let (path_noode,w) = node in if path_noode = b then ([path_noode],w) else let (path,cost) = aux_list (neighbours g path_noode) visited in if (List.length path... |
let open_account (initial_pass: passwd) : bank_account = let password = ref initial_pass in let balance = ref 0 in let number = ref 5 in { update_pass = (fun old_pwd new_pwd -> (if (old_pwd <> !password) then begin number := !number - 1; raise wrong_pass; end else number := 5; password := new_pwd; ) ); retrieve = (fun ... |
let neighbours (g: 'a graph) (vertex: 'a) : ('a * weight) list = if g.edges = [] then failwith "invalid input" else let rec check_neigh neigh list_neights = match neigh with | [] -> list_neights | (orig,dest,weight) :: tl -> if orig = vertex then check_neigh tl list_neights@[(dest,weight)] else check_neigh tl list_neig... |
let find_path (g: 'a graph) (a: 'a) (b: 'a) : ('a list * weight) = let rec aux_node (node: 'a * weight) (visited : 'a list) : ('a list * weight) = let (path_noode,w) = node in if path_noode = "" then raise Fail else if path_noode = b then ([path_noode],w) else let (path,cost) = aux_list (neighbours g path_noode) visite... |
let find_path' (g: 'a graph) (a: 'a) (b: 'a) : ('a list * weight) = let rec aux_node (node: 'a * weight) (visited : 'a list) fc sc : ('a list * weight)= let (path_noode,w) = node in if path_noode = b then sc ([path_noode],w) else let su2 = (fun (path,cost) -> if (List.length path) > 0 then sc (path_noode::path,cost+w) ... |
let find_longest_path (g: 'a graph) (a: 'a) (b: 'a) : ('a list * weight) option = let rec aux_node (node: 'a * weight) (visited : 'a list) : ('a list * weight) = let (path_noode,w) = node in if path_noode = b then ([path_noode],w) else let (path,cost) = aux_list (neighbours g path_noode) visited in if (List.length path... |
let open_account (initial_pass: passwd) : bank_account = let password = ref initial_pass in let balance = ref 0 in let number = ref 5 in { update_pass = ( fun old_pwd new_pwd -> ( if (old_pwd <> !password) then begin number := !number - 1; raise wrong_pass; end else number := 5; password := new_pwd; ) ); retrieve = ( f... |
let neighbours (g: 'a graph) (vertex: 'a) : ('a * weight) list = if g.edges = [] then failwith "invalid input" else let rec check_neigh neigh list_neights = match neigh with | [] -> list_neights | (orig,dest,weight) :: tl -> if orig = vertex then check_neigh tl list_neights@[(dest,weight)] else check_neigh tl list_neig... |
let find_path (g: 'a graph) (a: 'a) (b: 'a) : ('a list * weight) = let rec aux_node (node: 'a * weight) (visited : 'a list) : ('a list * weight) = let (path_noode,w) = node in if path_noode = b then ([path_noode],w) else let (path,cost) = aux_list (neighbours g path_noode) visited in if (List.length path) > 0 then (pat... |
let find_path' (g: 'a graph) (a: 'a) (b: 'a) : ('a list * weight) = let rec aux_node (node: 'a * weight) (visited : 'a list) fc sc : ('a list * weight)= let (path_noode,w) = node in if path_noode = b then sc ([path_noode],w) else let su2 = (fun (path,cost) -> if (List.length path) > 0 then sc (path_noode::path,cost+w) ... |
let find_longest_path (g: 'a graph) (a: 'a) (b: 'a) : ('a list * weight) option = let rec longest all_path longest_path = let (path_longest,cost_longest) = longest_path in match all_path with | [] -> Some longest_path | (path,cost) :: tl -> if cost >= cost_longest then longest tl (path,cost) else longest tl longest_pat... |
let open_account (initial_pass: passwd) : bank_account = let password = ref initial_pass in let balance = ref 0 in let number = ref 5 in { update_pass = ( fun old_pwd new_pwd -> ( if (old_pwd <> !password) then begin number := !number - 1; raise wrong_pass; end else number := 5; password := new_pwd; ) ); retrieve = ( f... |
let neighbours (g: 'a graph) (vertex: 'a) : ('a * weight) list = if g.edges = [] then failwith "invalid input" else let rec check_neigh neigh list_neights = match neigh with | [] -> list_neights | (orig,dest,weight) :: tl -> if orig = vertex then check_neigh tl list_neights@[(dest,weight)] else check_neigh tl list_neig... |
let find_path (g: 'a graph) (a: 'a) (b: 'a) : ('a list * weight) = let rec aux_node (node: 'a * weight) (visited : 'a list) : ('a list * weight) = let (path_noode,w) = node in if path_noode = b then ([path_noode],w) else let (path,cost) = aux_list (neighbours g path_noode) visited in if (List.length path) > 0 then (pat... |
let find_path' (g: 'a graph) (a: 'a) (b: 'a) : ('a list * weight) = let rec aux_node (node: 'a * weight) (visited : 'a list) fc sc : ('a list * weight)= let (path_noode,w) = node in if path_noode = b then sc ([path_noode],w) else let su2 = (fun (path,cost) -> if (List.length path) > 0 then sc (path_noode::path,cost+w) ... |
let find_longest_path (g: 'a graph) (a: 'a) (b: 'a) : ('a list * weight) option = let rec longest all_path longest_path = let (_,cost_longest) = longest_path in match all_path with | [] -> Some longest_path | (path,cost) :: tl -> if cost > cost_longest then longest tl (path,cost) else longest tl longest_path in if List... |
let open_account (initial_pass: passwd) : bank_account = let password = ref initial_pass and account_balance = ref 0 and wrong_pass_counter = ref 0 in { update_pass = (fun(old_password : passwd) (new_password : passwd) -> if old_password = !password then (password := new_password; wrong_pass_counter := 0) else (wrong_p... |
let neighbours (g: 'a graph) (vertex: 'a) : ('a * weight) list = List.fold_right (fun (v1, v2, w) acc -> if v1 = vertex then (v2, w) :: acc else acc) g.edges [];; |
let find_path (g: 'a graph) (a: 'a) (b: 'a) : ('a list * weight) = let rec aux_node (node: 'a * weight) (visited : 'a list) : ('a list * weight) = if fst(node) = b then ([b], snd(node)) and aux_list (nodes: ('a * weight) list) (visited: 'a list) : ('a list * weight) = notimplemented() in notimplemented();; |
let find_path' (g: 'a graph) (a: 'a) (b: 'a) : ('a list * weight) = let rec aux_node (node: 'a * weight) (visited : 'a list) fc sc : ('a list * weight)= notimplemented () and aux_list (nodes: ('a * weight) list) (visited: 'a list) fc sc : ('a list * weight) = notimplemented () in notimplemented ();; |
let find_longest_path (g: 'a graph) (a: 'a) (b: 'a) : ('a list * weight) option = notimplemented () *);; |
let open_account (initial_pass: passwd) : bank_account = let passt=ref 0 in let ipass= ref initial_pass in let b = ref 0 in { update_pass = (fun passwd1 passwd2 -> if passwd1 <> !ipass then (raise wrong_pass; if !passt > 5 then raise too_many_failures ; passt:= (!passt + 1)) else ipass:= passwd2); retrieve = ( fun pass... |
let neighbours (g: 'a graph) (vertex: 'a) : ('a * weight) list = match g with |[];; |
let find_path (g: 'a graph) (a: 'a) (b: 'a) : ('a list * weight) = let rec aux_node (node: 'a * weight) (visited : 'a list) : ('a list * weight) = notimplemented () and aux_list (nodes: ('a * weight) list) (visited: 'a list) : ('a list * weight) = notimplemented () in notimplemented ();; |
let find_path' (g: 'a graph) (a: 'a) (b: 'a) : ('a list * weight) = let rec aux_node (node: 'a * weight) (visited : 'a list) fc sc : ('a list * weight)= notimplemented () and aux_list (nodes: ('a * weight) list) (visited: 'a list) fc sc : ('a list * weight) = notimplemented () in notimplemented ();; |
let find_longest_path (g: 'a graph) (a: 'a) (b: 'a) : ('a list * weight) option = notimplemented ();; |
let open_account (initial_pass: passwd) : bank_account = let password = ref initial_pass in let balance = ref 0 in let wrong = ref 0 in { update_pass = ( fun old_pass new_pass -> ( if old_pass = !password then (password := new_pass ; wrong := 0) else (wrong := (!wrong + 1); raise wrong_pass) )); retrieve = ( fun pass a... |
let neighbours (g: 'a graph) (vertex: 'a) : ('a * weight) list = let f a b = ( let (a1,a2,w) = a in if a1 = vertex then (List.append [(a2,w)] b) else List.append [] b) in List.fold_right f g.edges [];; |
let find_path (g: 'a graph) (a: 'a) (b: 'a) : ('a list * weight) = let initial_neighbours = neighbours g a in let equal_node (node,weight) = (node = b) in let found = List.find_opt equal_node initial_neighbours in match found with |None -> ( let rec aux_node total_weight (node: 'a * weight) (visited : 'a list) : ('a li... |
let find_path' (g: 'a graph) (a: 'a) (b: 'a) : ('a list * weight) = let initial_neighbours = neighbours g a in let equal_node (node,weight) = (node = b) in let found = List.find_opt equal_node initial_neighbours in match found with |Some (node,weight) -> ([a;b],weight) |None -> ( let rec aux_node (node: 'a * weight) (v... |
let find_longest_path (g: 'a graph) (a: 'a) (b: 'a) : ('a list * weight) option = let paths = find_all_paths g a b in let l = List.length paths in if l = 0 then None else let rec compare current list = match list with |[] -> current |hd::tl -> let (cur_l,cur_w) = current in let (next_l,next_w) = hd in if next_w > cur_w... |
let open_account (initial_pass: passwd) : bank_account = let balance = ref 0 in let counter = ref 0 in let password = ref initial_pass in { update_pass = (fun (old_pass: passwd) (new_pass: passwd) -> ( if (old_pass = !password) then (password := new_pass; counter:= 0) else (counter := !counter +1; raise wrong_pass))); ... |
let neighbours (g: 'a graph) (vertex: 'a) : ('a * weight) list = let edges = g.edges in let rec neighbours_rec input_list output_list : ('a * weight) list = match input_list with | hd::hd2::tl -> (match hd with | (first, second, third) -> if first = vertex then (let output_list = output_list @ [(second, third)] in neig... |
let find_path (g: 'a graph) (a: 'a) (b: 'a) : ('a list * weight) = let rec aux_node (node: 'a * weight) (visited : 'a list) : ('a list * weight) = notimplemented () and aux_list (nodes: ('a * weight) list) (visited: 'a list) : ('a list * weight) = notimplemented () in notimplemented ();; |
let find_path' (g: 'a graph) (a: 'a) (b: 'a) : ('a list * weight) = let rec aux_node (node: 'a * weight) (visited : 'a list) fc sc : ('a list * weight)= notimplemented () and aux_list (nodes: ('a * weight) list) (visited: 'a list) fc sc : ('a list * weight) = notimplemented () in notimplemented ();; |
let find_longest_path (g: 'a graph) (a: 'a) (b: 'a) : ('a list * weight) option = notimplemented ();; |
let open_account (initial_pass: passwd) : bank_account = let balance = ref 0 in let counter = ref 0 in let password = ref initial_pass in { update_pass = (fun (old_pass: passwd) (new_pass: passwd) -> ( if (old_pass = !password) then (password := new_pass; counter:= 0) else (counter := !counter +1; raise wrong_pass))); ... |
let neighbours (g: 'a graph) (vertex: 'a) : ('a * weight) list = let edges = g.edges in let rec neighbours_rec input_list output_list : ('a * weight) list = match input_list with | hd::hd2::tl -> (match hd with | (first, second, third) -> if first = vertex then (let output_list = output_list @ [(second, third)] in neig... |
let find_path (g: 'a graph) (a: 'a) (b: 'a) : ('a list * weight) = let rec aux_node (node: 'a * weight) (visited : 'a list) : ('a list * weight) = notimplemented () and aux_list (nodes: ('a * weight) list) (visited: 'a list) : ('a list * weight) = notimplemented () in notimplemented ();; |
let find_path' (g: 'a graph) (a: 'a) (b: 'a) : ('a list * weight) = let rec aux_node (node: 'a * weight) (visited : 'a list) fc sc : ('a list * weight)= notimplemented () and aux_list (nodes: ('a * weight) list) (visited: 'a list) fc sc : ('a list * weight) = notimplemented () in notimplemented ();; |
let find_longest_path (g: 'a graph) (a: 'a) (b: 'a) : ('a list * weight) option = notimplemented ();; |
let open_account (initial_pass: passwd) : bank_account = let curr_pass = ref initial_pass in let balance = ref 0 in let fails = ref 0 in let check_pass = function pass -> if !fails = 5 then raise too_many_failures else if pass = !curr_pass then (fails := 0; true) else (fails := 1 + !fails; false) in let update_pass = f... |
let neighbours (g: 'a graph) (vertex: 'a) : ('a * weight) list = let rec filter edges vertex acc = match edges with | [] -> acc | x::xs -> let v1,v2,w = x in if v1 = vertex then filter xs vertex ((v2,w)::acc) else filter xs vertex acc in filter g.edges vertex [];; |
let find_path (g: 'a graph) (a: 'a) (b: 'a) : ('a list * weight) = let rec aux_node (node: 'a * weight) (visited : 'a list) : ('a list * weight) = let rec contains x l = match l with | [] -> false | h::t -> h=x || contains x t in let n,w = node in if contains n visited then raise Fail else if n = b then ([b],w) else le... |
let find_path' (g: 'a graph) (a: 'a) (b: 'a) : ('a list * weight) = let rec aux_node (node: 'a * weight) (visited : 'a list) fc sc : ('a list * weight)= let n,w = node in let rec contains x l = match l with | [] -> false | h::t -> h=x || contains x t in if contains n visited then fc() else if n = b then sc([b], w) else... |
let find_longest_path (g: 'a graph) (a: 'a) (b: 'a) : ('a list * weight) option = let rec get_longest l = match l with | [] -> None | [single_el] -> Some single_el | h::xs when xs <> [] -> ( match xs with | [] -> None | m::t -> let _,w1 = h in let _,w2 = m in match w1 >= w2 with | true -> get_longest (h::t) | false -> ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.