Re: [Batteries-discuss] how to get an IntSet and a FloatSet with batteries
Gabriel Scherer <[email protected]>
| Newsgroups | gmane.comp.lang.ocaml.beginners |
|---|---|
| Message-ID | <CAPFanBGEFa5F3pUx6NZETiFjoKbLHqb9BvY_sv2WiXorcFToew@mail.gmail.com> |
if you have shortened the Bat* module names, module IntSet = Set.Make(Int) should be enough (the BatInt module provides the type and comparison). There is no of_list and to_list, though, so you may still add them with your "include" trick or use enumerations instead. On Mon, Jan 6, 2014 at 9:54 AM, Francois Berenger <[email protected]> wrote: > On 01/06/2014 05:41 PM, Francois Berenger wrote: > >> Hi, >> >> I currently use Set.Make but I guess there are already >> cooked alternatives. >> >> Additional bonus points: how to add the functions of_list and to_list to >> those sets? >> > > I have this currently but I feel it is too long: > > module IntSet = struct > include Set.Make( > struct type t = int > let compare = cmp_int > end) > (* extend type with more operations *) > let of_list = L.fold_left (fun acc x -> add x acc) empty > let to_list = elements > end > > > to_list should be an alias for elements >> >> Thanks a lot, >> F. >> _______________________________________________ >> Batteries-discuss mailing list >> [email protected] >> https://lists.forge.ocamlcore.org/cgi-bin/listinfo/batteries-discuss >> > > > -- > Best regards, > Francois Berenger. > > _______________________________________________ > Batteries-discuss mailing list > [email protected] > https://lists.forge.ocamlcore.org/cgi-bin/listinfo/batteries-discuss >