From: Matt Gushee <mgushee@havenrock.com>
To: caml-list@inria.fr
Subject: Re: [Caml-list] Map + Set
Date: Sun, 25 Jul 2004 10:26:08 -0600 [thread overview]
Message-ID: <20040725162608.GA26605@swordfish> (raw)
In-Reply-To: <Pine.LNX.4.44.0407251548560.1419-100000@localhost>
On Sun, Jul 25, 2004 at 04:17:55PM +0800, Martin Jambon wrote:
>
> I need a functional data structure that has a decent efficiency (i.e.
> not lists) and can represent `sets of named containers' so that I can
> find a container in a set, remove it from the set, update it and put it
> back into the set.
>
> val find : elt -> t -> elt (* yes! *)
>
> Finally I just copy-pasted set.mli and set.ml and inserted a find
> function... but is there a better solution?
What I did when faced with a similar problem was:
module MySet =
struct
module BaseSet = Set.Make(
struct
....
end)
include BaseSet
let find elt set = ...
end
Now of course that will only handle one data type. If you want
polymorphism, I suppose you could try something like:
module MySet =
struct
module Make =
functor(SomeMod:SOMETYPE) ->
struct
include Set.Make
let find elt set = ...
end
....
end
Though I haven't tried the more general approach.
--
Matt Gushee When a nation follows the Way,
Englewood, Colorado, USA Horses bear manure through
mgushee@havenrock.com its fields;
http://www.havenrock.com/ When a nation ignores the Way,
Horses bear soldiers through
its streets.
--Lao Tzu (Peter Merel, trans.)
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
next prev parent reply other threads:[~2004-07-25 16:26 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-07-25 8:17 Martin Jambon
2004-07-25 16:26 ` Matt Gushee [this message]
2004-07-25 17:01 ` Brian Hurt
2004-07-26 10:40 ` Matthieu Sozeau
2004-07-26 15:25 ` Brian Hurt
2004-07-26 15:47 ` Martin Jambon
2004-07-26 16:26 ` Brian Hurt
2004-07-26 7:43 ` Diego Olivier Fernandez Pons
2004-07-26 16:24 ` Martin Jambon
2004-07-26 16:52 ` Diego Olivier Fernandez Pons
2004-07-27 21:45 ` [Caml-list] Camlp4 help/questions Josh Smith
2004-07-27 22:11 ` Brian Hurt
2004-07-28 1:15 ` Josh Smith
[not found] ` <200407272307.50167.jon@jdh30.plus.com>
2004-07-28 1:38 ` Josh Smith
2004-07-28 8:03 ` Pierre Weis
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20040725162608.GA26605@swordfish \
--to=mgushee@havenrock.com \
--cc=caml-list@inria.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox