EmilySeville7cfg 路 2022-12-28 10:13
I wanna obtain smth (sequence or generator) as a function argument and if it's a sequence transform it to generator. As I am writting LINQ-like package for Emacs I need understand how properly work with lazy things like generators.
deaddyfreddy 路 2022-12-28 10:39
I'm not sure if Emacs lisp has lazy sequences at all
EmilySeville7cfg 路 2022-12-28 10:42
It has yield-s and generators (which I name here as "lazy sequences"). 馃榿
helm05 路 2022-12-29 07:21
Emacs generators are quite complicated to use.
I generally use simplest things like this:
```
(defun iter-list (seq &optional cycle)
(let ((lis seq))
(lambda ()
(let ((elm (car lis)))
(setq lis (if cycle
(or (cdr lis) seq)
(cdr lis)))
elm))))
(setq foo (iter-list '(a b c d e f)))
(funcall foo)
```
deaddyfreddy 路 2022-12-29 13:32
are you talking about https://nicolas.petton.fr/blog/stream.html ? It's not an Emacs built-in, but an ELPA package.
bikenaga 路 2022-12-29 15:49
OP is probably referring to the generators described in Sec. 11.6 of the elisp manual - iter-defun, iter-lambda, and so on.
EmilySeville7cfg 路 2022-12-29 20:39
Yes, I am referring to them. :)