Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set.map #6279

Closed
vicuna opened this Issue Dec 21, 2013 · 4 comments

Comments

Projects
None yet
2 participants
@vicuna
Copy link
Collaborator

commented Dec 21, 2013

Original bug ID: 6279
Reporter: @dbuenzli
Assigned to: @gasche
Status: resolved (set by @alainfrisch on 2016-12-06T18:37:19Z)
Resolution: fixed
Priority: normal
Severity: feature
Version: 4.01.0
Target version: 4.03.1+dev
Fixed in version: 4.04.0
Category: standard library

Bug description

would 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.

@vicuna

This comment has been minimized.

Copy link
Collaborator Author

commented Jan 30, 2014

Comment author: braibant

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...

@vicuna

This comment has been minimized.

Copy link
Collaborator Author

commented Feb 4, 2014

Comment author: @alainfrisch

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

@vicuna

This comment has been minimized.

Copy link
Collaborator Author

commented Feb 19, 2014

Comment author: @damiendoligez

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

@vicuna

This comment has been minimized.

Copy link
Collaborator Author

commented Apr 18, 2016

Comment author: @gasche

I'm postponing this to 4.04, but I proposed a pull request at:

#553

@vicuna vicuna closed this Dec 6, 2016

@vicuna vicuna added the stdlib label Mar 14, 2019

@vicuna vicuna added this to the 4.03.1 milestone Mar 14, 2019

@vicuna vicuna referenced this issue Mar 14, 2019

Closed

Set.disjoint #6450

@vicuna vicuna added the feature-wish label Mar 20, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.