forked from CakeML/candle
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnets.ml.patch
62 lines (62 loc) · 2.06 KB
/
nets.ml.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
38c38
< let enter =
---
> let enter lconsts =
49,59d48
< let canon_eq x y =
< try Pervasives.compare x y = 0 with Invalid_argument _ -> false
< and canon_lt x y =
< try Pervasives.compare x y < 0 with Invalid_argument _ -> false in
< let rec sinsert x l =
< if l = [] then [x] else
< let h = hd l in
< if canon_eq h x then failwith "sinsert" else
< if canon_lt x h then x::l else
< h::(sinsert x (tl l)) in
< let set_insert x l = try sinsert x l with Failure "sinsert" -> l in
62c51
< [] -> Netnode(edges,set_insert elem tips)
---
> [] -> Netnode(edges,tips @ [elem])
70c59
< fun lconsts (tm,elem) net -> net_update lconsts (elem,[tm],net);;
---
> fun (tm,elem) net -> net_update lconsts (elem,[tm],net);;
76c65
< let lookup =
---
> let lookup tm =
94c83
< fun tm net -> follow([tm],net);;
---
> fun net -> follow([tm],net);;
100,120c89,95
< let merge_nets =
< let canon_eq x y =
< try Pervasives.compare x y = 0 with Invalid_argument _ -> false
< and canon_lt x y =
< try Pervasives.compare x y < 0 with Invalid_argument _ -> false in
< let rec set_merge l1 l2 =
< if l1 = [] then l2
< else if l2 = [] then l1 else
< let h1 = hd l1 and t1 = tl l1
< and h2 = hd l2 and t2 = tl l2 in
< if canon_eq h1 h2 then h1::(set_merge t1 t2)
< else if canon_lt h1 h2 then h1::(set_merge t1 l2)
< else h2::(set_merge l1 t2) in
< let rec merge_nets (Netnode(l1,data1),Netnode(l2,data2)) =
< let add_node ((lab,net) as p) l =
< try let (lab',net'),rest = remove (fun (x,y) -> x = lab) l in
< (lab',merge_nets (net,net'))::rest
< with Failure _ -> p::l in
< Netnode(itlist add_node l2 (itlist add_node l1 []),
< set_merge data1 data2) in
< merge_nets;;
---
> let rec merge_nets (Netnode(l1,data1),Netnode(l2,data2)) =
> let add_node ((lab,net) as p) l =
> try let (lab',net'),rest = remove (fun (x,y) -> x = lab) l in
> (lab',merge_nets (net,net'))::rest
> with Failure _ -> p::l in
> Netnode(itlist add_node l2 (itlist add_node l1 []),
> data1 @ data2);;