all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Nicolas Petton <nicolas@petton.fr>
To: Michael Heerdegen <michael_heerdegen@web.de>,
	Emacs Development <emacs-devel@gnu.org>
Cc: Stefan Monnier <monnier@iro.umontreal.ca>
Subject: Re: Stream implementation of seq-mapn
Date: Mon, 18 Dec 2017 13:32:17 +0100	[thread overview]
Message-ID: <87po7crzce.fsf@petton.fr> (raw)
In-Reply-To: <87lgi0fdt3.fsf@web.de>

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

Michael Heerdegen <michael_heerdegen@web.de> writes:

Hi Michael,

> [...]
> +(cl-defmethod seq-mapn (function (stream stream) &rest streams)
> +  "Map FUNCTION over the STREAMS.

I would add to the docstring that all elements of `streams' should be
streams, otherwise it will default to the generic implementation.

> +
> +Example: this prints the first ten Fibonacci numbers:
> +
> +  (letrec ((fibs (stream-cons
> +                  1
> +                  (stream-cons
> +                   1
> +                   (seq-mapn #'+ fibs (stream-rest fibs))))))
> +    (seq-do #'print (seq-take fibs 10)))
> +
> +\(fn FUNCTION STREAMS...)"
> +  (if (not (cl-every #'streamp streams))
               ^^^^^^^^
               Since this is for stream.el, why not use `seq-every-p'?
> +      (cl-call-next-method)
> +    (cl-callf2 cons stream streams)
> +    (stream-make
> +     (unless (cl-some #'seq-empty-p streams)
                 ^^^^^^^
                 Same question :-)
> [...]


> (1) Is it ok to implement it with `cl-call-next-method' this way?

I guess it is.  Have you tried running `seq-mapn' with a mix of streams
and lists?

Cheers,
Nico

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

  reply	other threads:[~2017-12-18 12:32 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-18 11:58 Stream implementation of seq-mapn Michael Heerdegen
2017-12-18 12:32 ` Nicolas Petton [this message]
2017-12-18 12:51   ` Michael Heerdegen
2017-12-18 13:50     ` Nicolas Petton
2017-12-19 13:05       ` Michael Heerdegen
2017-12-19 14:08         ` Nicolas Petton
2017-12-26 22:09           ` Michael Heerdegen
2017-12-29  9:04             ` Nicolas Petton
2017-12-30 14:28               ` Michael Heerdegen

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

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

  git send-email \
    --in-reply-to=87po7crzce.fsf@petton.fr \
    --to=nicolas@petton.fr \
    --cc=emacs-devel@gnu.org \
    --cc=michael_heerdegen@web.de \
    --cc=monnier@iro.umontreal.ca \
    /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 external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.