Re: [Batteries-discuss] how to get an IntSet and a FloatSet with batteries
Francois Berenger <[email protected]>
| Newsgroups | gmane.comp.lang.ocaml.beginners |
|---|---|
| Message-ID | <[email protected]> |
On 01/07/2014 01:32 AM, Gabriel Scherer wrote: > if you have shortened the Bat* module names, > module IntSet = Set.Make(Int) > should be enough (the BatInt module provides the type and comparison). OK, thanks for all the propositions. > There is no of_list and to_list, though, so you may still add them with > your "include" trick or use enumerations instead. I see that of_list and to_list are in the trunk but not in the batteries package in OPAM. I'll stay away from enums for the moment (never had a real need for them yet). > On Mon, Jan 6, 2014 at 9:54 AM, Francois Berenger <[email protected] > <mailto:[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].__ocamlcore.org > <mailto:[email protected]> > https://lists.forge.ocamlcore.__org/cgi-bin/listinfo/__batteries-discuss > <https://lists.forge.ocamlcore.org/cgi-bin/listinfo/batteries-discuss> > > > > -- > Best regards, > Francois Berenger. > > _________________________________________________ > Batteries-discuss mailing list > [email protected].__ocamlcore.org > <mailto:[email protected]> > https://lists.forge.ocamlcore.__org/cgi-bin/listinfo/__batteries-discuss > <https://lists.forge.ocamlcore.org/cgi-bin/listinfo/batteries-discuss> > > -- Best regards, Francois Berenger.