[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).
Sure.
> 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.
Thanks,
Michael.
- Re: Emacs 26.2.90 is out!, (continued)
- Re: Emacs 26.2.90 is out!, Nicolas Petton, 2019/06/12
- Re: Emacs 26.2.90 is out!, Phillip Lord, 2019/06/13
- stream.el (was: Emacs 26.2.90 is out!), Michael Heerdegen, 2019/06/13
- Re: Enhance seq-min and seq-max, Michael Heerdegen, 2019/06/15
- Re: Enhance seq-min and seq-max, Nicolas Petton, 2019/06/16
- Re: Enhance seq-min and seq-max,
Michael Heerdegen <=
- Re: Enhance seq-min and seq-max, Nicolas Petton, 2019/06/17
- Re: Enhance seq-min and seq-max, Michael Heerdegen, 2019/06/25
- Re: Enhance seq-min and seq-max, Nicolas Petton, 2019/06/26