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
Closed

Set.map #6279

vicuna opened this issue Dec 21, 2013 · 4 comments
Assignees
Milestone

Comments

@vicuna
Copy link

vicuna 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
Copy link
Author

vicuna 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
Copy link
Author

vicuna 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
Copy link
Author

vicuna 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
Copy link
Author

vicuna 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 as completed 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 mentioned this issue Mar 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants