minor details

This commit is contained in:
Simon Cruanes 2014-05-12 14:57:28 +02:00
parent 88f006171f
commit 9edb610132
3 changed files with 7 additions and 3 deletions

View file

@ -45,7 +45,9 @@ let make f f_len r r_len = match f with
let singleton x = make [x] 1 [] 0 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 let length l = l.f_len + l.r_len

View file

@ -37,7 +37,8 @@ val singleton : 'a -> 'a t
val of_list : 'a list -> 'a t val of_list : 'a list -> 'a t
(** build a circular list from a list. Linear in the length (** 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 val length : 'a t -> int
(** length of the cycle. *) (** length of the cycle. *)

View file

@ -78,7 +78,7 @@ The signature for a given string representation provides 3 main things:
maximal distance). maximal distance).
A possible use of the index could be: A possible use of the index could be:
[ {[
open Batteries;; open Batteries;;
let words = File.with_file_in "/usr/share/dict/english" 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;; let idx = Levenshtein.Index.of_list words;;
Levenshtein.Index.retrieve ~limit:1 idx "hell" |> Levenshtein.klist_to_list;; Levenshtein.Index.retrieve ~limit:1 idx "hell" |> Levenshtein.klist_to_list;;
]}
*) *)
module type S = sig module type S = sig