caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Radu Grigore <radugrigore@gmail.com>
To: Gabriel Scherer <gabriel.scherer@gmail.com>
Cc: fa.caml@googlegroups.com, Caml List <caml-list@inria.fr>
Subject: Re: [Caml-list] Writing the function Set.map using first-class modules and 4.00 inference
Date: Mon, 5 Nov 2012 12:02:03 +0000	[thread overview]
Message-ID: <CACMRfCyu_oYsYBsB=XEHXj9ONwtQAdTe7qotQRe9UBYzONEDTw@mail.gmail.com> (raw)
In-Reply-To: <CAPFanBFF-onqLFqSaa200kKS9Bxx2roE47YorfQd4L2BoUzkPg@mail.gmail.com>

On Mon, Nov 5, 2012 at 10:12 AM, Gabriel Scherer
<gabriel.scherer@gmail.com> wrote:
> You haven't tested the bad case, where the list is nearly sorted but
> not exactly

It's 3.7% slower, rather than 3.6% for random lists. (But, you
shouldn't be calling it "*the* bad case".)

> Another problem is that you call the
> user-defined comparison more than necessary, [...]

I would note only that the "necessary" number of comparisons is not
really achieved with your optimization, for the simple reason that the
minimum number of comparisons is hard to compute. [1]

> pay costs that a demanding user could request to skip by having
> of_sorted_list and of_list exposed directly, and making the choice
> herself.

I'm not sure what costs you are talking about:
(1) If it's the case of sorted lists, then that user is already paying
a much bigger price now.
(2) It it's the case of non-sorted lists, then the demanding user can
always do what they do now.

> A note on API design: [...] My personal opinion is that we
> should preserve the abstraction of Set and Map, reject all operations
> that rely on a representation assumption of sorted balanced trees
> (unfortunately some of them, such as split, have already crept in),

The (of_list : elt list -> t) function relies on no assumption about
how the set is implemented. With *any* reasonable implementation of a
set, you should be able to build it from a list. The only reason to
*not* put it in the interface would be if the user could write an
implementation that is just as good. But they can't.

[1] http://oeis.org/A036604

  reply	other threads:[~2012-11-05 12:02 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <fa.yP8czrxqEGCABee05wzAlISIlN4@ifi.uio.no>
     [not found] ` <fa.rve4x46ugIvZs4BizovvjOCeTG0@ifi.uio.no>
     [not found]   ` <fa.i9E+7rAvghoTZ1MXH4g+uL4dpCY@ifi.uio.no>
     [not found]     ` <fa.AX0JYJa8kXsH/YSZ08tuyBc8m+0@ifi.uio.no>
     [not found]       ` <fa.YAoOn2iUcpHbr53eeBfGhPTDvtM@ifi.uio.no>
2012-11-05  8:05         ` Radu Grigore
2012-11-05 10:12           ` Gabriel Scherer
2012-11-05 12:02             ` Radu Grigore [this message]
     [not found] <fa.FUGAe9RTYsSPA4RwbpKO14B0oVo@ifi.uio.no>
2012-11-02 14:59 ` Radu Grigore
2012-11-02 15:11   ` Radu Grigore
2012-11-02 16:00     ` Gabriel Scherer
2012-11-02 16:21       ` Radu Grigore
2012-11-01 21:00 Jeff Meister

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='CACMRfCyu_oYsYBsB=XEHXj9ONwtQAdTe7qotQRe9UBYzONEDTw@mail.gmail.com' \
    --to=radugrigore@gmail.com \
    --cc=caml-list@inria.fr \
    --cc=fa.caml@googlegroups.com \
    --cc=gabriel.scherer@gmail.com \
    /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;
as well as URLs for NNTP newsgroup(s).