unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Nicolas Petton <nicolas@petton.fr>
To: Michael Heerdegen <michael_heerdegen@web.de>
Cc: Emacs Devel <emacs-devel@gnu.org>
Subject: Re: Enhance seq-min and seq-max
Date: Sun, 16 Jun 2019 22:11:01 +0200	[thread overview]
Message-ID: <87imt59tpm.fsf@petton.fr> (raw)
In-Reply-To: <87wohm76ox.fsf@web.de>

[-- Attachment #1: Type: text/plain, Size: 1524 bytes --]

Michael Heerdegen <michael_heerdegen@web.de> writes:

> Michael Heerdegen <michael_heerdegen@web.de> writes:

Hi Michael,

>> Like this, maybe?

I like the idea!  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?
> +      (if key
> +          (let ((first (car sequence)))
                           ^^^
                           You cannot use `car' here
> +            (cdr (seq-reduce
> +                  (lambda (key-x-and-x y)
> +                    (let ((key-y-and-y (cons (funcall key y) y)))
> +                      (if (funcall predicate (car key-y-and-y) (car key-x-and-x))
> +                          key-y-and-y
> +                        key-x-and-x)))
> +                  (cdr sequence)
                      ^^^
                      You cannot use `cdr' either
> +                  (cons (funcall key first) first))))
> +        (seq-reduce
> +         (lambda (x y) (if (funcall predicate y x) y x))
> +         (cdr sequence) (car sequence)))
> +    (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'.

Thanks!
Nico

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 487 bytes --]

  reply	other threads:[~2019-06-16 20:11 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-12 20:09 Emacs 26.2.90 is out! Nicolas Petton
2019-06-12 21:31 ` Nicolas Petton
2019-06-13 21:35 ` Phillip Lord
2019-06-13 23:03 ` stream.el (was: Emacs 26.2.90 is out!) Michael Heerdegen
2019-06-14  7:15   ` Nicolas Petton
2019-06-15  0:25     ` Enhance seq-min and seq-max (was: stream.el) Michael Heerdegen
2019-06-15  6:27       ` Eli Zaretskii
2019-06-15 23:00         ` Enhance seq-min and seq-max Michael Heerdegen
2019-06-16  2:38           ` Eli Zaretskii
2019-06-15 23:46       ` Michael Heerdegen
2019-06-16 20:11         ` Nicolas Petton [this message]
2019-06-16 23:21           ` Michael Heerdegen
2019-06-17  7:46             ` Nicolas Petton
2019-06-25 21:22               ` Michael Heerdegen
2019-06-26  7:52                 ` Nicolas Petton

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/emacs/

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

  git send-email \
    --in-reply-to=87imt59tpm.fsf@petton.fr \
    --to=nicolas@petton.fr \
    --cc=emacs-devel@gnu.org \
    --cc=michael_heerdegen@web.de \
    /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.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

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).