Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0006279OCamlOCaml standard librarypublic2013-12-21 14:322014-07-16 18:05
Reporterdbuenzli 
Assigned To 
PrioritynormalSeverityminorReproducibilityhave not tried
StatusacknowledgedResolutionopen 
PlatformOSOS Version
Product Version4.01.0 
Target Version4.03.0+devFixed in Version 
Summary0006279: Set.map
Descriptionwould be nice. I have already written the following a few times in my life:

module Sset = Set.Make(String)
let sset_map f s = Sset.fold (fun e acc -> Sset.add (f e) acc) s Sset.empty

Thanks.
TagsNo tags attached.
Attached Files

- Relationships

-  Notes
(0010869)
braibant (reporter)
2014-01-30 21:54

Also, in the same vein, I find myself writing a "of_list" function quite often

module MSet = struct
  module Make(E:Set.OrderedType) =
  struct
    include Set.Make(E)
    let of_list l = List.fold_right (add) l empty
  end
end

I agree that this is a one-liner, but a frequent one...
(0010878)
frisch (developer)
2014-02-04 11:12
edited on: 2014-02-04 11:13

@braibant: Set.of_list has already been added to trunk (will be available in OCaml 4.02), with a somewhat optimized implementation. See 0004986.

(0010953)
doligez (administrator)
2014-02-19 17:17
edited on: 2014-02-19 17:17

May I remind everyone that the best place for such functions is "extended" libraries like Batteries and Jane Street Core?


- Issue History
Date Modified Username Field Change
2013-12-21 14:32 dbuenzli New Issue
2014-01-30 21:54 braibant Note Added: 0010869
2014-02-04 11:12 frisch Note Added: 0010878
2014-02-04 11:13 frisch Note Edited: 0010878 View Revisions
2014-02-19 17:17 doligez Note Added: 0010953
2014-02-19 17:17 doligez Note Edited: 0010953 View Revisions
2014-05-30 13:46 shinwell Status new => acknowledged
2014-07-16 18:05 doligez Target Version => 4.03.0+dev


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker