[Top][All Lists]

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

Re: Enhance seq-min and seq-max

From: Michael Heerdegen
Subject: Re: Enhance seq-min and seq-max
Date: Mon, 17 Jun 2019 01:21:32 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)

Nicolas Petton <address@hidden> writes:

> In addition to documentation, could you also add unit tests? (for
> seq.el, I like when my unit tests test multiple sequence types).


> I left some comments below.
> > +  (if predicate
>          ^^^^^^^^^
> What if `predicate' is nil but `key' is non-nil?

Then it does nonsense.  Ok, we get one more case.  I wonder if I should
rather give one general definition in the function body and handle the
four cases (KEY/PREDICATE given/not given) in a compiler macro.  Then in
compiled code there would be no runtime tests and it would be optimized
for the respective case.

> > +    (apply #'min (seq-into sequence 'list))))
>                      ^^^^^^^^^^^^^^^^^^^^^^^ I think your version of
>                      `seq-min' will break when `predicate' is used for
>                      all sequence types but lists, since you don't
>                      convert the sequence, but use `car' and `cdr'.

Correct.  I changed it to use seq-first and seq-rest instead of car/cdr
- an intermediate conversion step is not necessary I think.



reply via email to

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