[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Stream implementation of seq-mapn
From: |
Nicolas Petton |
Subject: |
Re: Stream implementation of seq-mapn |
Date: |
Mon, 18 Dec 2017 13:32:17 +0100 |
Michael Heerdegen <address@hidden> 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
signature.asc
Description: PGP signature
- Stream implementation of seq-mapn, Michael Heerdegen, 2017/12/18
- Re: Stream implementation of seq-mapn,
Nicolas Petton <=
- Re: Stream implementation of seq-mapn, Michael Heerdegen, 2017/12/18
- Re: Stream implementation of seq-mapn, Nicolas Petton, 2017/12/18
- Re: Stream implementation of seq-mapn, Michael Heerdegen, 2017/12/19
- Re: Stream implementation of seq-mapn, Nicolas Petton, 2017/12/19
- Re: Stream implementation of seq-mapn, Michael Heerdegen, 2017/12/26
- Re: Stream implementation of seq-mapn, Nicolas Petton, 2017/12/29
- Re: Stream implementation of seq-mapn, Michael Heerdegen, 2017/12/30