diff --git a/circList.ml b/circList.ml index 9a63e380..fda92d1f 100644 --- a/circList.ml +++ b/circList.ml @@ -45,7 +45,9 @@ let make f f_len r r_len = match f with let singleton x = make [x] 1 [] 0 -let of_list l = make l (List.length l) [] 0 +let of_list l = + if l = [] then raise (Invalid_argument "empty list"); + make l (List.length l) [] 0 let length l = l.f_len + l.r_len diff --git a/circList.mli b/circList.mli index fdec46ef..9638e616 100644 --- a/circList.mli +++ b/circList.mli @@ -37,7 +37,8 @@ val singleton : 'a -> 'a t val of_list : 'a list -> 'a t (** build a circular list from a list. Linear in the length - of the list *) + of the list. + @raise Invalid_argument if the list is empty *) val length : 'a t -> int (** length of the cycle. *) diff --git a/levenshtein.mli b/levenshtein.mli index 0f4e5e87..d571415e 100644 --- a/levenshtein.mli +++ b/levenshtein.mli @@ -78,7 +78,7 @@ The signature for a given string representation provides 3 main things: maximal distance). A possible use of the index could be: -[ +{[ open Batteries;; let words = File.with_file_in "/usr/share/dict/english" @@ -88,6 +88,7 @@ let words = List.map (fun s->s,s) words;; let idx = Levenshtein.Index.of_list words;; Levenshtein.Index.retrieve ~limit:1 idx "hell" |> Levenshtein.klist_to_list;; +]} *) module type S = sig