[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] Gnu Elpa: stream.el: Add some more basic stream operations
From: |
Michael Heerdegen |
Subject: |
Re: [PATCH] Gnu Elpa: stream.el: Add some more basic stream operations |
Date: |
Fri, 10 Jun 2016 17:57:21 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/25.0.94 (gnu/linux) |
Yuri Khan <address@hidden> writes:
> A left fold which forces the intermediate result before recurring has
> good space complexity, but can only be lazy in the values of the
> elements, not their number.
AFAIK we only have left fold in seq.el (a right fold wouldn't make sense
for infinite streams anyway). Every calculation is turned into a loop
where possible, since Emacs Lisp sucks at recursion.
If we had `seq-take-until', one could use that to stop folding at an
absorbing element, like in
#+begin_src emacs-lisp
(seq-reduce
#'*
(seq-take-until
(lambda (x) (not (zerop x)))
(stream-range -3)) ;-3, -2, -1, 0, 1, 2,...
1)
==> 0
#+end_src
Would it make sense to add an `seq-take-until' for convenience?
> https://wiki.haskell.org/Foldr_Foldl_Foldl'
Note for readers from the future: the quote at the end is part of the
url.
Regards,
Michael.
- Re: [PATCH] Gnu Elpa: stream.el: Add some more basic stream operations, (continued)
- Re: [PATCH] Gnu Elpa: stream.el: Add some more basic stream operations, Michael Heerdegen, 2016/06/02
- Re: [PATCH] Gnu Elpa: stream.el: Add some more basic stream operations, Michael Heerdegen, 2016/06/08
- Re: [PATCH] Gnu Elpa: stream.el: Add some more basic stream operations, Nicolas Petton, 2016/06/09
- Re: [PATCH] Gnu Elpa: stream.el: Add some more basic stream operations, Michael Heerdegen, 2016/06/09
- Re: [PATCH] Gnu Elpa: stream.el: Add some more basic stream operations, Nicolas Petton, 2016/06/09
- Re: [PATCH] Gnu Elpa: stream.el: Add some more basic stream operations, Davis Herring, 2016/06/09
- Re: [PATCH] Gnu Elpa: stream.el: Add some more basic stream operations, Michael Heerdegen, 2016/06/09
- Re: [PATCH] Gnu Elpa: stream.el: Add some more basic stream operations, Yuri Khan, 2016/06/09
- Re: [PATCH] Gnu Elpa: stream.el: Add some more basic stream operations, Michael Heerdegen, 2016/06/09
- Re: [PATCH] Gnu Elpa: stream.el: Add some more basic stream operations, Yuri Khan, 2016/06/09
- Re: [PATCH] Gnu Elpa: stream.el: Add some more basic stream operations,
Michael Heerdegen <=
- Re: [PATCH] Gnu Elpa: stream.el: Add some more basic stream operations, Yuri Khan, 2016/06/10
- Re: [PATCH] Gnu Elpa: stream.el: Add some more basic stream operations, Michael Heerdegen, 2016/06/10
- Re: [PATCH] Gnu Elpa: stream.el: Add some more basic stream operations, Markus Triska, 2016/06/12
- Re: [PATCH] Gnu Elpa: stream.el: Add some more basic stream operations, Michael Heerdegen, 2016/06/12
- Re: [PATCH] Gnu Elpa: stream.el: Add some more basic stream operations, Nicolas Petton, 2016/06/12
- Re: [PATCH] Gnu Elpa: stream.el: Add some more basic stream operations, Markus Triska, 2016/06/12
- Re: [PATCH] Gnu Elpa: stream.el: Add some more basic stream operations, Michael Heerdegen, 2016/06/10
Re: [PATCH] Gnu Elpa: stream.el: Add some more basic stream operations, Nicolas Petton, 2016/06/09