[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#17485: [PATCH 2/3] Rewrite take-right, drop-right, drop-right!

From: David Kastrup
Subject: bug#17485: [PATCH 2/3] Rewrite take-right, drop-right, drop-right!
Date: Sat, 20 Sep 2014 17:15:23 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4.50 (gnu/linux)

Mark H Weaver <address@hidden> writes:

> David Kastrup <address@hidden> 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 via email to

[Prev in Thread] Current Thread [Next in Thread]