diff options
author | Samuel Mimram <smimram@debian.org> | 2006-04-28 14:59:16 +0000 |
---|---|---|
committer | Samuel Mimram <smimram@debian.org> | 2006-04-28 14:59:16 +0000 |
commit | 3ef7797ef6fc605dfafb32523261fe1b023aeecb (patch) | |
tree | ad89c6bb57ceee608fcba2bb3435b74e0f57919e /lib/explore.ml | |
parent | 018ee3b0c2be79eb81b1f65c3f3fa142d24129c8 (diff) |
Imported Upstream version 8.0pl3+8.1alphaupstream/8.0pl3+8.1alpha
Diffstat (limited to 'lib/explore.ml')
-rw-r--r-- | lib/explore.ml | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/lib/explore.ml b/lib/explore.ml index 2eaabef8..7e6de0c4 100644 --- a/lib/explore.ml +++ b/lib/explore.ml @@ -6,7 +6,7 @@ (* * GNU Lesser General Public License Version 2.1 *) (************************************************************************) -(*i $Id: explore.ml,v 1.3.16.1 2004/07/16 19:30:29 herbelin Exp $ i*) +(*i $Id: explore.ml 6066 2004-09-06 22:54:50Z barras $ i*) open Format @@ -37,6 +37,7 @@ module Make = functor(S : SearchProblem) -> struct if S.success s then s else depth_first_many (S.branching s) and depth_first_many = function | [] -> raise Not_found + | [s] -> depth_first s | s :: l -> try depth_first s with Not_found -> depth_first_many l let debug_depth_first s = @@ -44,8 +45,8 @@ module Make = functor(S : SearchProblem) -> struct pp_position p; S.pp s; if S.success s then s else explore_many 1 p (S.branching s) and explore_many i p = function - | [] -> - raise Not_found + | [] -> raise Not_found + | [s] -> explore (i::p) s | s :: l -> try explore (i::p) s with Not_found -> explore_many (succ i) p l in @@ -67,10 +68,8 @@ module Make = functor(S : SearchProblem) -> struct let breadth_first s = let rec explore q = - try - let (s, q') = pop q in enqueue q' (S.branching s) - with Empty -> - raise Not_found + let (s, q') = try pop q with Empty -> raise Not_found in + enqueue q' (S.branching s) and enqueue q = function | [] -> explore q | s :: l -> if S.success s then s else enqueue (push s q) l @@ -79,11 +78,8 @@ module Make = functor(S : SearchProblem) -> struct let debug_breadth_first s = let rec explore q = - try - let ((p,s), q') = pop q in - enqueue 1 p q' (S.branching s) - with Empty -> - raise Not_found + let ((p,s), q') = try pop q with Empty -> raise Not_found in + enqueue 1 p q' (S.branching s) and enqueue i p q = function | [] -> explore q |