aboutsummaryrefslogtreecommitdiff
path: root/motus/lib/wordlist.ml
blob: 7c400bb2ebafde61f0e9da3e78f3f4c8e414dc7a (plain)
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
open StdLabels
module S = Set.Make (String)

type t = S.t

let empty_data () = S.empty

let add_words : Criteria.t list -> string Seq.t -> t =
 fun filters words ->
  Seq.filter
    (fun word -> List.for_all ~f:(Criteria.check_filter word) filters)
    words
  |> S.of_seq


let filter : Criteria.t list -> t -> t =
 fun filters t ->
  S.filter (fun word -> List.for_all ~f:(Criteria.check_filter word) filters) t


let words = S.to_seq

let list_size = S.cardinal

let remove_word t w = S.remove w t