text
stringlengths
0
601k
let open_account (initial_pass: passwd) : bank_account = let password = ref initial_pass in let numAttempts = ref 0 in let balance = ref 0 in let password_checker pass bank_account_func = if pass = !password then (numAttempts := 0; bank_account_func ()) else (numAttempts := !numAttempts + 1; raise wrong_pass) in let at...
let neighbours (g: 'a graph) (vertex: 'a) : ('a * weight) list = notimplemented ();;
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_count = ref 0 in let incr () = wrong_count := !wrong_count + 1 in let reset () = wrong_count := 0 in let auth pass = if !wrong_count >= 5 then raise too_many_failures else if pass <> !password th...
let neighbours (g: 'a graph) (vertex: 'a) : ('a * weight) list = List.fold_left (fun ns (v1, v2, w) -> if v1 = vertex then (v2, w)::ns else ns) [] 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 (v, w) = node in if List.mem v visited then raise Fail else if v = b then ([v], w) else let (ns, wt) = aux_list (neighbours g v) (v::visited) in (v::ns, w + wt) and aux_...
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 (v, w) = node in if List.mem v visited then fc () else if v = b then sc ([v], w) else aux_list (neighbours g v) (v::visited) fc (fun (ns, wt) -> sc (v::ns, w + wt)...
let find_longest_path (g: 'a graph) (a: 'a) (b: 'a) : ('a list * weight) option = match find_all_paths g a b with | [] -> None | ps -> Some ( List.fold_left (fun (p, w) (p', w') -> if w' > w then (p', w') else (p, w)) ([], 0) ps);;
let open_account (initial_pass: passwd) : bank_account = let password = ref initial_pass in let counter = ref 0 in let balance = ref 0 in { update_pass = (fun x y -> if x = !password then begin counter := 0; password := y; end else begin counter := !counter + 1; raise wrong_pass; end;) ; retrieve = (fun x y -> if !coun...
let neighbours (g: 'a graph) (vertex: 'a) : ('a * weight) list = List.fold_right (fun (v1, v2, w) l -> if v1 = vertex then (v2,w) :: l else l) g.edges [];;
let find_path (g: 'a graph) (a: 'a) (b: 'a) : ('a list * weight) = let rec aux_node node visited weight = let adj = neighbours g node in match adj with | [] -> raise Fail | (x,w)::xs -> if x = b then (visited @ [x], weight + w) else if not(List.mem x visited) then try aux_node x (visited @ [x]) (weight + w) with Fail -...
let find_path' (g: 'a graph) (a: 'a) (b: 'a) : ('a list * weight) = let rec aux_node node visited weight fc sc = let adj = neighbours g node in match adj with | [] -> fc () | (x,w)::xs -> if x = b then sc ((visited @ [x], weight + w)) else if not(List.mem x visited) then try aux_node x (visited @ [x]) (weight + w) fc s...
let find_longest_path (g: 'a graph) (a: 'a) (b: 'a) : ('a list * weight) option = let list = find_all_paths g a b in match list with | [] -> None | l -> Some (List.hd( List.rev( List.sort( fun (_,x) (_,y) -> if x > y then 1 else if y > x then -1 else 0) l)));;
let open_account (initial_pass: passwd) : bank_account = let num_failures = ref 0 in let password = ref initial_pass in let curr_balance = ref 0 in { update_pass = ( fun old_passwd -> fun new_passwd -> if old_passwd = !password then (num_failures := 0 ; password := new_passwd) else (num_failures := (!num_failures + 1) ...
let neighbours (g: 'a graph) (vertex: 'a) : ('a * weight) list = let rec neighbour_helper (e: ('a * 'a * weight) list) (vertex: 'a) (acc: ('a * weight) list): ('a * weight) list = match e with | [] -> acc | x :: xs -> let (v1, v2, w) = x in if v1 = vertex then (neighbour_helper xs vertex ((v2, w) :: acc)) else (neighbo...
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 (a,w) = node in if a = b then let path = visited@[b] in (path, (get_path_weight g path 0)) else try aux_list (neighbours g a) (visited@[a]) with Fail -> raise Fail and a...
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 (a,_) = node in if a = b then let path = visited@[b] in sc (path, (get_path_weight g path 0)) else aux_list (neighbours g a) (visited@[a]) fc sc and aux_list (node...
let find_longest_path (g: 'a graph) (a: 'a) (b: 'a) : ('a list * weight) option = let all_paths = find_all_paths g a b in match all_paths with | [] -> None | _ -> let f = fun (path_long, w_long) -> fun (path_curr, w_curr) -> if w_curr > w_long then (path_curr, w_curr) else (path_long, w_long) in Some (List.fold_left f ...
let check_pass (pass : passwd) (correct_pass : passwd) (counter : int ref) (lock : bool ref) : unit = if !lock && pass = correct_pass then raise (Locked "correct password") else if !lock then raise (Locked "incorrect password") else if pass = correct_pass then ( counter := 0; raise CorrectPasswordProvided) else ( count...
let open_account (initial_pass : passwd) : bank_account = let lock = ref false in let pswd_attempt_counter = ref 0 in let pswd = ref initial_pass in let balance = ref 0 in { update_pass = (fun old nw -> try check_pass old !pswd pswd_attempt_counter lock with | CorrectPasswordProvided | Locked "correct password" -> lock...
let neighbours (g : 'a graph) (vertex : 'a) : ('a * weight) list = if not (List.exists (fun s -> s = vertex) g.nodes) then raise VertexDoesNotExist else let f (ls : ('a * weight) list) (edge : 'a * 'a * weight) = let origin, dest, w = edge in match origin with o when o = vertex -> (dest, w) :: ls | _ -> ls in List.fold...
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 v, w = node in let neighbours_list = List.map (fun (a, individual_weight) -> let collective_weight = individual_weight + w in (a, collective_weight)) (neighbours g v) in...
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 v, w = node in let neighbours_list = List.map (fun (a, individual_weight) -> let collective_weight = individual_weight + w in (a, collective_weight)) (neighbours ...
let find_longest_path (g: 'a graph) (a: 'a) (b: 'a) : ('a list * weight) option = notimplemented ();;
let check_pass (pass : passwd) (correct_pass : passwd) (counter : int ref) (lock : bool ref) : unit = if !lock && pass = correct_pass then raise (Locked "correct password") else if !lock then raise (Locked "incorrect password") else if pass = correct_pass then ( counter := 0; raise CorrectPasswordProvided) else ( count...
let open_account (initial_pass : passwd) : bank_account = let lock = ref false in let pswd_attempt_counter = ref 0 in let pswd = ref initial_pass in let balance = ref 0 in { update_pass = (fun old nw -> try check_pass old !pswd pswd_attempt_counter lock with | CorrectPasswordProvided | Locked "correct password" -> lock...
let neighbours (g : 'a graph) (vertex : 'a) : ('a * weight) list = if not (List.exists (fun s -> s = vertex) g.nodes) then raise VertexDoesNotExist else let f (ls : ('a * weight) list) (edge : 'a * 'a * weight) = let origin, dest, w = edge in match origin with o when o = vertex -> (dest, w) :: ls | _ -> ls in List.fold...
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 v, w = node in let neighbours_list = List.map (fun (a, individual_weight) -> let collective_weight = individual_weight + w in (a, collective_weight)) (neighbours g v) in...
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 v, w = node in let neighbours_list = List.map (fun (a, individual_weight) -> let collective_weight = individual_weight + w in (a, collective_weight)) (neighbours ...
let find_longest_path (g : 'a graph) (a : 'a) (b : 'a) : ('a list * weight) option = let paths = find_all_paths g a b in if paths = [] then None else let longest_path = ref ([ b ], -1) in let _ = List.map (fun (path, w) -> let _, max_weight = !longest_path in if w > max_weight then longest_path := (path, w)) paths in S...
let check_pass (pass : passwd) (correct_pass : passwd) (counter : int ref) (lock : bool ref) : unit = if !lock && pass = correct_pass then raise (Locked "correct password") else if !lock then raise (Locked "incorrect password") else if pass = correct_pass then ( counter := 0; raise CorrectPasswordProvided) else ( count...
let open_account (initial_pass : passwd) : bank_account = let lock = ref false in let pswd_attempt_counter = ref 0 in let pswd = ref initial_pass in let balance = ref 0 in { update_pass = (fun old nw -> try check_pass old !pswd pswd_attempt_counter lock with | CorrectPasswordProvided | Locked "correct password" -> lock...
let neighbours (g : 'a graph) (vertex : 'a) : ('a * weight) list = if not (List.exists (fun s -> s = vertex) g.nodes) then raise VertexDoesNotExist else let f (ls : ('a * weight) list) (edge : 'a * 'a * weight) = let origin, dest, w = edge in match origin with o when o = vertex -> (dest, w) :: ls | _ -> ls in List.fold...
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 v, w = node in let neighbours_list = List.map (fun (a, individual_weight) -> let collective_weight = individual_weight + w in (a, collective_weight)) (neighbours g v) in...
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 v, w = node in let neighbours_list = List.map (fun (a, individual_weight) -> let collective_weight = individual_weight + w in (a, collective_weight)) (neighbours ...
let find_longest_path (g: 'a graph) (a: 'a) (b: 'a) : ('a list * weight) option = notimplemented ();;
let check_pass (pass : passwd) (correct_pass : passwd) (counter : int ref) (lock : bool ref) : unit = if !lock && pass = correct_pass then raise (Locked "correct password") else if !lock then raise (Locked "incorrect password") else if pass = correct_pass then ( counter := 0; raise CorrectPasswordProvided) else ( count...
let open_account (initial_pass : passwd) : bank_account = let lock = ref false in let pswd_attempt_counter = ref 0 in let pswd = ref initial_pass in let balance = ref 0 in { update_pass = (fun old nw -> try check_pass old !pswd pswd_attempt_counter lock with | CorrectPasswordProvided | Locked "correct password" -> lock...
let neighbours (g : 'a graph) (vertex : 'a) : ('a * weight) list = if not (List.exists (fun s -> s = vertex) g.nodes) then raise VertexDoesNotExist else let f (ls : ('a * weight) list) (edge : 'a * 'a * weight) = let origin, dest, w = edge in match origin with o when o = vertex -> (dest, w) :: ls | _ -> ls in List.fold...
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 v, w = node in let neighbours_list = List.map (fun (a, individual_weight) -> let collective_weight = individual_weight + w in (a, collective_weight)) (neighbours g v) in...
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 v, w = node in let neighbours_list = List.map (fun (a, individual_weight) -> let collective_weight = individual_weight + w in (a, collective_weight)) (neighbours ...
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 current_pass = ref initial_pass and counter = ref 0 and balance = ref 0 in { update_pass = (fun x y -> if x = !current_pass then begin current_pass := y; counter := 0 end else begin counter := !counter + 1; raise wrong_pass end); deposit = (fun x y -> if !cou...
let neighbours (g: 'a graph) (vertex: 'a) : ('a * weight) list = let rec neighbs g vertex out = match g with | (x,y,z)::tl -> if x = vertex then neighbs tl vertex [(y,z)]@out else neighbs tl vertex out | [] -> out in neighbs g.edges vertex [];;
let find_path (g: 'a graph) (a: 'a) (b: 'a) : ('a list * weight) = if a = b then ([a],0) else let rec pathfinder a b visited weight= match a with | [] -> raise Fail | (x,y)::tl -> if x = b then (visited@[b], weight+y) else try pathfinder tl b visited weight with Fail -> if not (List.mem x visited) then pathfinder (neig...
let find_path' (g: 'a graph) (a: 'a) (b: 'a) : ('a list * weight) = if a = b then ([a],0) else let rec pathfinder g' a b visited k = match g' with | [] -> raise Fail | (x,y)::tl -> if x = b then k (visited@[x]) y else try pathfinder tl a b visited k with Fail -> if not (List.mem x visited) then pathfinder (neighbours g...
let find_longest_path (g: 'a graph) (a: 'a) (b: 'a) : ('a list * weight) option = let count = 0 in let rec pathfinder longest visited= match longest with | [] -> if count = 0 then None else Some(visited, count) | (x,w)::tl -> if w > count then pathfinder tl x else pathfinder tl visited in pathfinder (find_all_paths g a...
let open_account (initial_pass: passwd) : bank_account = let current_pass = ref initial_pass and counter = ref 0 and balance = ref 0 in { update_pass = (fun x y -> if x = !current_pass then begin current_pass := y; counter := 0 end else begin counter := !counter + 1; raise wrong_pass end); deposit = (fun x y -> if !cou...
let neighbours (g: 'a graph) (vertex: 'a) : ('a * weight) list = let rec neighbs g vertex out = match g with | (x,y,z)::tl -> if x = vertex then neighbs tl vertex [(y,z)]@out else neighbs tl vertex out | [] -> out in neighbs g.edges vertex [];;
let find_path (g: 'a graph) (a: 'a) (b: 'a) : ('a list * weight) = if a = b then ([a],0) else let rec pathfinder a b visited weight= match a with | [] -> raise Fail | (x,y)::tl -> if x = b then (visited@[b], weight+y) else try pathfinder tl b visited weight with Fail -> if not (List.mem x visited) then pathfinder (neig...
let find_path' (g: 'a graph) (a: 'a) (b: 'a) : ('a list * weight) = if a = b then ([a],0) else let rec pathfinder g' a b visited k = match g' with | [] -> raise Fail | (x,y)::tl -> if x = b then k (visited@[x]) y else try pathfinder tl a b visited k with Fail -> if not (List.mem x visited) then pathfinder (neighbours g...
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 pass = ref initial_pass in let counter = ref 0 in let balance = ref 0 in let update_pass old_pass new_pass = if (old_pass = !pass) then let _ = counter := 0 in pass := new_pass else let _ = counter := !counter + 1 in raise wrong_pass in let deposit p amount =...
let neighbours (g: 'a graph) (vertex: 'a) : ('a * weight) list = let check_edge (v1, _, _) = v1 = vertex in List.map (fun (_, v2, w) -> (v2, w)) (List.filter check_edge g.edges) ;; let filter_nodes nodes visited = let check_node (node, w) = not (List.exists (fun v -> node = v) visited) in List.filter check_node nodes ;...
let find_path (g: 'a graph) (a: 'a) (b: 'a) : ('a list * weight) = let rec aux_list (nodes: ('a * weight) list) (visited: 'a list) cost : ('a list * weight) = let nodes_to_visit = filter_nodes nodes visited in match nodes_to_visit with | [] -> raise Fail | (n, w) :: xs -> if (n = b) then (List.append visited [n], cost ...
let find_path' (g: 'a graph) (a: 'a) (b: 'a) : ('a list * weight) = let rec aux_list (nodes: ('a * weight) list) (visited: 'a list) cost fc : ('a list * weight) = let nodes_to_visit = filter_nodes nodes visited in match nodes_to_visit with | [] -> fc () | (n, w) :: xs -> if (n = b) then (List.append visited [n], cost +...
let find_longest_path (g: 'a graph) (a: 'a) (b: 'a) : ('a list * weight) option = let paths = find_all_paths g a b in if ((List.length paths) = 0) then None else let compare_paths (p1, c1) (p2, c2) = if (c1 = c2) then ( if (List.length p1 > List.length p2) then (p1, c1) else (p2, c2) ) else ( if (c1 > c2) then (p1, c1)...
let open_account (initial_pass: passwd) : bank_account = let pass = ref initial_pass in let counter = ref 0 in let balance = ref 0 in let update_pass old_pass new_pass = if (old_pass = !pass) then let _ = counter := 0 in pass := new_pass else let _ = counter := !counter + 1 in raise wrong_pass in let deposit p amount =...
let neighbours (g: 'a graph) (vertex: 'a) : ('a * weight) list = let check_edge (v1, _, _) = v1 = vertex in List.map (fun (_, v2, w) -> (v2, w)) (List.filter check_edge g.edges) ;; let filter_nodes nodes visited = let check_node (node, _) = not (List.exists (fun v -> node = v) visited) in List.filter check_node nodes ;...
let find_path (g: 'a graph) (a: 'a) (b: 'a) : ('a list * weight) = let rec aux_list (nodes: ('a * weight) list) (visited: 'a list) cost : ('a list * weight) = let nodes_to_visit = filter_nodes nodes visited in match nodes_to_visit with | [] -> raise Fail | (n, w) :: xs -> if (n = b) then (List.append visited [n], cost ...
let find_path' (g: 'a graph) (a: 'a) (b: 'a) : ('a list * weight) = let rec aux_list (nodes: ('a * weight) list) (visited: 'a list) cost fc : ('a list * weight) = let nodes_to_visit = filter_nodes nodes visited in match nodes_to_visit with | [] -> fc () | (n, w) :: xs -> if (n = b) then (List.append visited [n], cost +...
let find_longest_path (g: 'a graph) (a: 'a) (b: 'a) : ('a list * weight) option = let paths = find_all_paths g a b in if ((List.length paths) = 0) then None else let compare_paths (p1, c1) (p2, c2) = if (c1 = c2) then ( if (List.length p1 > List.length p2) then (p1, c1) else (p2, c2) ) else ( if (c1 > c2) then (p1, c1)...
let open_account (initial_pass: passwd) : bank_account = let pass = ref initial_pass in let counter = ref 0 in let balance = ref 0 in let update_pass old_pass new_pass = if (old_pass = !pass) then let _ = counter := 0 in pass := new_pass else let _ = counter := !counter + 1 in raise wrong_pass in let deposit p amount =...
let neighbours (g: 'a graph) (vertex: 'a) : ('a * weight) list = let check_edge (v1, _, _) = v1 = vertex in List.map (fun (_, v2, w) -> (v2, w)) (List.filter check_edge g.edges) ;; let filter_nodes nodes visited = let check_node (node, _) = not (List.exists (fun v -> node = v) visited) in List.filter check_node nodes ;...
let find_path (g: 'a graph) (a: 'a) (b: 'a) : ('a list * weight) = let rec aux_list (nodes: ('a * weight) list) (visited: 'a list) cost : ('a list * weight) = let nodes_to_visit = filter_nodes nodes visited in match nodes_to_visit with | [] -> raise Fail | (n, w) :: xs -> if (n = b) then (List.append visited [n], cost ...
let find_path' (g: 'a graph) (a: 'a) (b: 'a) : ('a list * weight) = let rec aux_list (nodes: ('a * weight) list) (visited: 'a list) cost sc fc : ('a list * weight) = let nodes_to_visit = filter_nodes nodes visited in match nodes_to_visit with | [] -> fc () | (n, w) :: xs -> if (n = b) then sc (List.append visited [n], ...
let find_longest_path (g: 'a graph) (a: 'a) (b: 'a) : ('a list * weight) option = let paths = find_all_paths g a b in if ((List.length paths) = 0) then None else let compare_paths (p1, c1) (p2, c2) = if (c1 = c2) then ( if (List.length p1 > List.length p2) then (p1, c1) else (p2, c2) ) else ( if (c1 > c2) then (p1, c1)...
let open_account (initial_pass: passwd) : bank_account = let password = ref initial_pass and balance = ref 0 and nb_attempt = ref 0 in { update_pass = ( fun (old_pass: passwd) (new_pass: passwd) -> if old_pass <> !password then (incr nb_attempt; raise wrong_pass) else (nb_attempt := 0; password := new_pass) ); retrieve...
let neighbours (g: 'a graph) (vertex: 'a) : ('a * weight) list = List.fold_left ( fun init_ls edge -> let (v1, v2, w) = edge in if v1 = vertex then init_ls@[(v2,w)] else init_ls ) ([]) (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) (tot_cost: weight): ('a list * weight) = let (vertex, cost) = node in let tot_cost = tot_cost + cost in if vertex = b then let new_visited = visited@[vertex] in (new_visited, tot_cost) else if Lis...
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 = let all_paths = (find_all_paths g a b) in if all_paths = [] then None else let sorted_descending_paths = List.sort (fun x y -> let x = (snd x) and y = (snd y) in if x<y then 1 else if x>y then -1 else 0) all_paths in Some (List.hd sorted_...
let open_account (initial_pass: passwd) : bank_account = let password = ref initial_pass and balance = ref 0 and nb_attempt = ref 0 in { update_pass = ( fun (old_pass: passwd) (new_pass: passwd) -> if old_pass <> !password then (incr nb_attempt; raise wrong_pass) else (nb_attempt := 0; password := new_pass) ); retrieve...
let neighbours (g: 'a graph) (vertex: 'a) : ('a * weight) list = List.fold_left ( fun init_ls edge -> let (v1, v2, w) = edge in if v1 = vertex then init_ls@[(v2,w)] else init_ls ) ([]) (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) (tot_cost: weight): ('a list * weight) = let (vertex, cost) = node in let tot_cost = tot_cost + cost in if vertex = b then let new_visited = visited@[vertex] in (new_visited, tot_cost) else if Lis...
let find_path' (g: 'a graph) (a: 'a) (b: 'a) : ('a list * weight) = let rec aux_node (node: 'a * weight) (visited : 'a list) (tot_cost: weight) fc sc : ('a list * weight)= let (vertex, cost) = node in let tot_cost = tot_cost + cost in if vertex = b then let new_visited = visited@[vertex] in (new_visited, tot_cost) else...
let find_longest_path (g: 'a graph) (a: 'a) (b: 'a) : ('a list * weight) option = let all_paths = (find_all_paths g a b) in if all_paths = [] then None else let sorted_descending_paths = List.sort (fun x y -> let x = (snd x) and y = (snd y) in if x<y then 1 else if x>y then -1 else 0) all_paths in Some (List.hd sorted_...
let open_account (initial_pass: passwd) : bank_account = let password = ref initial_pass and balance = ref 0 and nb_attempt = ref 0 in { update_pass = ( fun (old_pass: passwd) (new_pass: passwd) -> if old_pass <> !password then (incr nb_attempt; raise wrong_pass) else (nb_attempt := 0; password := new_pass) ); retrieve...
let neighbours (g: 'a graph) (vertex: 'a) : ('a * weight) list = List.fold_left ( fun init_ls edge -> let (v1, v2, w) = edge in if v1 = vertex then init_ls@[(v2,w)] else init_ls ) ([]) (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) (tot_cost: weight): ('a list * weight) = let (vertex, cost) = node in let tot_cost = tot_cost + cost in if vertex = b then let new_visited = visited@[vertex] in (new_visited, tot_cost) else if Lis...
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 and balance = ref 0 and nb_attempt = ref 0 in { update_pass = ( fun (old_pass: passwd) (new_pass: passwd) -> if old_pass <> !password then (incr nb_attempt; raise wrong_pass) else (nb_attempt := 0; password := new_pass) ); retrieve...
let neighbours (g: 'a graph) (vertex: 'a) : ('a * weight) list = List.fold_left ( fun init_ls edge -> let (v1, v2, w) = edge in if v1 = vertex then init_ls@[(v2,w)] else init_ls ) ([]) (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) (tot_cost: weight): ('a list * weight) = let (vertex, cost) = node in let tot_cost = tot_cost + cost in if vertex = b then let new_visited = visited@[vertex] in (new_visited, tot_cost) else if Lis...
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 = let all_paths = (find_all_paths g a b) in if all_paths = [] then None else let sorted_descending_paths = List.sort (fun x y -> let x = (snd x) and y = (snd y) in if x<y then 1 else if x>y then -1 else 0) all_paths in Some (List.hd sorted_...
let open_account (initial_pass: passwd) : bank_account = let password = ref initial_pass and balance = ref 0 and nb_attempt = ref 0 in { update_pass = ( fun (old_pass: passwd) (new_pass: passwd) -> if old_pass <> !password then (incr nb_attempt; raise wrong_pass) else (nb_attempt := 0; password := new_pass) ); retrieve...
let neighbours (g: 'a graph) (vertex: 'a) : ('a * weight) list = List.fold_left ( fun init_ls edge -> let (v1, v2, w) = edge in if v1 = vertex then init_ls@[(v2,w)] else init_ls ) ([]) (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) (tot_cost: weight): ('a list * weight) = let (vertex, cost) = node in let tot_cost = tot_cost + cost in if vertex = b then let new_visited = visited@[vertex] in (new_visited, tot_cost) else if Lis...
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 = let all_paths = (find_all_paths g a b) in if all_paths = [] then None else let sorted_descending_paths = List.sort (fun x y -> let x = (snd x) and y = (snd y) in if x<y then 1 else if x>y then -1 else 0) all_paths in Some (List.hd sorted_...
let open_account (initial_pass: passwd) : bank_account = let password = ref initial_pass and balance = ref 0 and nb_attempt = ref 0 in { update_pass = ( fun (old_pass: passwd) (new_pass: passwd) -> if old_pass <> !password then (incr nb_attempt; raise wrong_pass) else (nb_attempt := 0; password := new_pass) ); retrieve...
let neighbours (g: 'a graph) (vertex: 'a) : ('a * weight) list = List.fold_left ( fun init_ls edge -> let (v1, v2, w) = edge in if v1 = vertex then init_ls@[(v2,w)] else init_ls ) ([]) (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) (tot_cost: weight): ('a list * weight) = let (vertex, cost) = node in let tot_cost = tot_cost + cost in if vertex = b then let new_visited = visited@[vertex] in (new_visited, tot_cost) else if Lis...
let find_path' (g: 'a graph) (a: 'a) (b: 'a) : ('a list * weight) = let rec aux_node (node: 'a * weight) (visited : 'a list) (tot_cost: weight) fc sc : ('a list * weight)= let (vertex, cost) = node in let tot_cost = tot_cost + cost in if vertex = b then let new_visited = visited@[vertex] in (new_visited, tot_cost) else...
let find_longest_path (g: 'a graph) (a: 'a) (b: 'a) : ('a list * weight) option = let all_paths = (find_all_paths g a b) in if all_paths = [] then None else let sorted_descending_paths = List.sort (fun x y -> let x = (snd x) and y = (snd y) in if x<y then 1 else if x>y then -1 else 0) all_paths in Some (List.hd sorted_...
let open_account (initial_pass: passwd) : bank_account = let balance = ref 0 in let password = ref initial_pass in let attempts = ref 0 in {update_pass = (fun old_pass new_pass -> if (old_pass <> !password) then (attempts := !attempts+1; raise wrong_pass) else password := new_pass; attempts := 0; ); deposit = (fun inpu...