unofficial mirror of bug-guile@gnu.org 
 help / color / mirror / Atom feed
From: David Kastrup <dak@gnu.org>
To: Mark H Weaver <mhw@netris.org>
Cc: 17485@debbugs.gnu.org
Subject: bug#17485: [PATCH 2/3] Rewrite take-right, drop-right, drop-right!
Date: Sat, 20 Sep 2014 17:15:23 +0200	[thread overview]
Message-ID: <87wq8ypblg.fsf@fencepost.gnu.org> (raw)
In-Reply-To: <87k34yl4s3.fsf@yeeloong.lan> (Mark H. Weaver's message of "Sat,  20 Sep 2014 10:56:12 -0400")

Mark H Weaver <mhw@netris.org> writes:

> David Kastrup <dak@gnu.org> writes:
>
>> * module/srfi/srfi-1.scm (take-right, drop-right, drop-right!): The
>>   definitions tended to be overly complicate and/or rely on pushing
>>   material on the VM stack, detrimental to scalability for Guile 2.0 and
>>   also worse for performance.
>>
>>   The changed definitions lead to different, more accurate exceptions
>>   being raised.  They rely on length+ returning the length of dotted
>>   lists, behavior that is not specified by the SRFI-1 definition but
>>   available in GUILE.
>
> Your patches look good to me, except that we can't change 'length+' as
> you propose.  Instead I'd like to add a lax variant of 'length+' with a
> different name, and use that.
>
> I can take care of doing this myself, and will of course still credit
> you in whatever manner you prefer, but I've run into a legal problem: we
> don't currently have copyright papers for you on file.  Are you willing
> to file copyright papers for GUILE?

No problems with that.  Standard request-assign?

At any rate, here is what I would suggest to create: a function
min-length receiving a list of lists (possibly as separate arguments via
a rest argument).

It will return the number of times one can do cdr on every of the given
arguments until at least one of them turns into a list end with nothing
turning into anything but a pair or a list end.

That would allow dotted lists as long as they are longer than any
non-dotted list.  It would still flag when scalars are being used
instead of dotted or undotted lists, the case you are worried about.

That would remain in the spirit of allowing lists of different length as
well as infinite lists, basically "as long as the list part matching the
shortest finite list is usable, let's take it".

While it would not make much sense to actually feed dotted lists into it
(as they will never be usable completely), it would speed up figuring
the minimum list length since there is no point doing cdr 50 times on
list 3 when list 1 has already been tested for being of length 10.

-- 
David Kastrup





  reply	other threads:[~2014-09-20 15:15 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-13 10:47 bug#17485: (srfi srfi-1) reduce-right does not scale, version 2.0.9 David Kastrup
2014-06-01 23:41 ` Mark H Weaver
2014-06-02  7:59   ` David Kastrup
2014-06-03 18:56 ` bug#17485: [PATCH 1/3] Let length+ return the length of dotted lists rather than #f David Kastrup
2014-06-03 18:56   ` bug#17485: [PATCH 2/3] Rewrite take-right, drop-right, drop-right! David Kastrup
2014-06-04  3:29     ` Mark H Weaver
2014-06-04  3:45     ` Mark H Weaver
2014-09-20 14:56     ` Mark H Weaver
2014-09-20 15:15       ` David Kastrup [this message]
2014-09-22 17:15         ` Mark H Weaver
2014-09-22 18:40           ` David Kastrup
2014-06-03 18:56   ` bug#17485: [PATCH 3/3] Reimplement reduce-right in srfi-1 David Kastrup
2014-06-04  3:30     ` Mark H Weaver
2014-06-04  3:42   ` bug#17485: [PATCH 1/3] Let length+ return the length of dotted lists rather than #f Mark H Weaver
2014-06-04  4:57     ` David Kastrup
2014-06-04 10:09       ` David Kastrup
2014-06-05 13:57         ` David Kastrup
2016-06-21 14:42 ` bug#17485: (srfi srfi-1) reduce-right does not scale, version 2.0.9 Andy Wingo
2016-06-21 15:31   ` David Kastrup
2016-07-12  7:07     ` Andy Wingo
2016-07-12  7:43 ` bug#17485: Ugh, well David Kastrup
2016-07-12 13:54   ` Andy Wingo

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

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87wq8ypblg.fsf@fencepost.gnu.org \
    --to=dak@gnu.org \
    --cc=17485@debbugs.gnu.org \
    --cc=mhw@netris.org \
    /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 read-only IMAP folder(s) and NNTP newsgroup(s).