From: "Frédéric Gava" <frederic.gava@wanadoo.fr>
To: <caml-list@inria.fr>
Subject: Fw: [Caml-list] Missing a function
Date: Sun, 30 Jan 2005 10:53:02 +0100 [thread overview]
Message-ID: <001901c506b1$7d89fb60$0100a8c0@mshome.net> (raw)
Hi,
>
> > Another option is to build on top of the stdlib Map functor another
> > functor that keeps track of the cardinal of a map :
> >
> > module CMap = functor (Ord : Map.OrderedType) ->
> > (struct
> > module M = Map.Make (Ord)
> >
> > type key = M.key
> > type 'a t = int * 'a M.t
> >
> > let cardinal = fst
> >
> > let empty = 0, M.empty
> >
> > let add k v (n, m) = (n + 1, M.add k v m)
> >
> > let find k (_, m) = M.find k m
> >
> > ....
> > : sig
> > include Map.S
> > val cardinal : 'a t -> int
> > end)
> >
Hum. To remove an element, you have to test is its exists or not before
decrease n. It could be to much cost expansive...no ?
Regards,
Frédéric Gava
next reply other threads:[~2005-01-30 9:51 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-01-30 9:53 Frédéric Gava [this message]
2005-01-30 12:14 ` Olivier Andrieu
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='001901c506b1$7d89fb60$0100a8c0@mshome.net' \
--to=frederic.gava@wanadoo.fr \
--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