[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Get generators working in an src block?

From: George Mauer
Subject: Get generators working in an src block?
Date: Sat, 4 Jul 2020 17:02:07 -0500

I prefer to use source blocks for pretty much all my language learning.

I am trying to figure out generators in emacs-lisp but can't seem to run it in a block.

I have

    #+begin_src emacs-lisp :results output
      (setq lexical-binding t)
      (require 'generator)

      (iter-defun my-iter (x)
        (let (val (iter-yield (1+ x)))
          (iter-yield (1+ val)))

      (let* ((it1 (my-iter 5))
             (it2 (my-itr 0)))
        (print (iter-next it1))
        (print (iter-next it1 8))
        (print (iter-next it2 nil))
        (condition-case x
            (iter-next it1)
           (print (cdr x)))))

But running that gives me

> executing Emacs-Lisp code block...
> cl--assertion-failed: Assertion failed: lexical-binding

I thought that setting lexical-binding to t was enough, but apparently something else is needed?

reply via email to

[Prev in Thread] Current Thread [Next in Thread]