Loading ...
Sorry, an error occurred while loading the content.

13996Re: [Batteries-discuss] how to get an IntSet and a FloatSet with batteries

Expand Messages
  • Francois Berenger
    Jan 6, 2014
    • 0 Attachment
      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 <berenger@...
      > <mailto:berenger@...>> 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
      > Batteries-discuss@....__ocamlcore.org
      > <mailto:Batteries-discuss@...>
      > 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
      > Batteries-discuss@....__ocamlcore.org
      > <mailto:Batteries-discuss@...>
      > https://lists.forge.ocamlcore.__org/cgi-bin/listinfo/__batteries-discuss
      > <https://lists.forge.ocamlcore.org/cgi-bin/listinfo/batteries-discuss>
      >
      >


      --
      Best regards,
      Francois Berenger.
    • Show all 7 messages in this topic