X-Git-Url: https://git.xandkar.net/?p=dups.git;a=blobdiff_plain;f=dups.ml;h=46e8b917c3d4227564758411119632f3f40a421f;hp=a1dca83c2e923745d5cf821f3654c0423dbe0a0b;hb=c66266c608c952190ad5fc8b82882cf15013ce26;hpb=1f130f74d08198f0c800ae84e1fbb4b94695e426 diff --git a/dups.ml b/dups.ml index a1dca83..46e8b91 100644 --- a/dups.ml +++ b/dups.ml @@ -58,25 +58,16 @@ end = struct () ) in - let next_dir () = - match Queue.take dirs with - | exception Queue.Empty -> - () - | dir -> - explore dir - in - let next_file () = - match Queue.take files with - | exception Queue.Empty -> - None - | file_path -> - Some file_path - in explore root; - Stream.create (fun () -> - next_dir (); - next_file () - ) + let rec next () = + match Queue.is_empty files, Queue.is_empty dirs with + | false, _ -> Some (Queue.take files) + | true , true -> None + | true , false -> + explore (Queue.take dirs); + next () + in + Stream.create next end type input =