unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Closures - do you understand them well?
@ 2022-12-08 15:36 Michael Heerdegen
  2022-12-08 16:24 ` [External] : " Drew Adams
                   ` (2 more replies)
  0 siblings, 3 replies; 86+ messages in thread
From: Michael Heerdegen @ 2022-12-08 15:36 UTC (permalink / raw)
  To: Emacs mailing list

Hi,

Maybe you will have fun with this new exercise:

What is the return value of the following expression, and what's your
reasoning?  Answer without asking Emacs:

#+begin_src emacs-lisp
;; -*- lexical-binding: t -*-

(let ((i 0)
      (funs '()))
  (while (< (setq i (1+ i))
            4)
    (push (lambda () i)
          funs))
  (apply #'+ (mapcar #'funcall funs)))
#+end_src

Please no "you better write this as ... and then it returns ..."
answers: I mean this code and what it returns.


Have fun!

Michael.



^ permalink raw reply	[flat|nested] 86+ messages in thread

end of thread, other threads:[~2023-03-03 12:19 UTC | newest]

Thread overview: 86+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-08 15:36 Closures - do you understand them well? Michael Heerdegen
2022-12-08 16:24 ` [External] : " Drew Adams
2022-12-08 17:30   ` Michael Heerdegen
2022-12-08 17:56     ` Drew Adams
2022-12-08 18:00       ` Drew Adams
2022-12-08 18:49       ` Michael Heerdegen
2022-12-08 19:35         ` Drew Adams
2022-12-10  4:51           ` Emanuel Berg
2022-12-08 19:45         ` Drew Adams
2022-12-08 19:06 ` Tassilo Horn
2022-12-08 19:53   ` Michael Heerdegen
2022-12-08 20:01     ` Stefan Monnier via Users list for the GNU Emacs text editor
2022-12-08 20:49       ` Michael Heerdegen
2022-12-08 22:00         ` Stefan Monnier via Users list for the GNU Emacs text editor
2022-12-08 22:25           ` [External] : " Drew Adams
2022-12-08 22:51             ` Stefan Monnier via Users list for the GNU Emacs text editor
2022-12-10  2:34               ` Emanuel Berg
2022-12-09  5:03             ` Tomas Hlavaty
2022-12-10  2:35               ` Emanuel Berg
2022-12-10  2:29             ` Emanuel Berg
2022-12-10 16:56               ` Drew Adams
2022-12-15  8:25                 ` Emanuel Berg
2022-12-09  4:49           ` tomas
2022-12-09 19:40             ` Michael Heerdegen
2022-12-09 19:50               ` tomas
2022-12-09 20:55               ` Tassilo Horn
2022-12-09 21:21                 ` Michael Heerdegen
2022-12-09 21:31                   ` Emanuel Berg
2022-12-09 21:23                 ` Emanuel Berg
2022-12-10 11:40                   ` tomas
2022-12-12  1:18                     ` Michael Heerdegen
2022-12-12  5:16                       ` tomas
2022-12-12  6:09                         ` Michael Heerdegen
2023-01-18 12:13                           ` Emanuel Berg
2023-01-19 13:21                             ` Michael Heerdegen
2023-01-27 20:24                               ` Emanuel Berg
2023-01-28  0:44                                 ` Michael Heerdegen
2023-02-26 12:45                                   ` Emanuel Berg
2023-02-27  8:33                                     ` tomas
2023-02-28 10:13                                     ` Michael Heerdegen
2023-03-01 20:42                                       ` Emanuel Berg
2023-03-03 12:09                                         ` Michael Heerdegen
2023-03-02 11:08                                       ` Michael Heerdegen
2023-03-02 18:25                                         ` Emanuel Berg
2023-03-02 20:48                                           ` Emanuel Berg
2023-03-03  6:56                                             ` Eli Zaretskii
2023-03-03 12:19                                             ` Michael Heerdegen
2023-03-02 18:37                                         ` Emanuel Berg
2023-03-02 18:50                                         ` Emanuel Berg
2023-01-18 12:11                         ` Emanuel Berg
2022-12-22  4:00                     ` Emanuel Berg
2022-12-23  6:27                       ` tomas
2023-01-18 12:23                         ` Emanuel Berg
2022-12-10  4:46                 ` Emanuel Berg
2022-12-10  0:12               ` Michael Heerdegen
2022-12-10  9:34                 ` Tassilo Horn
2022-12-10 10:02                   ` Emanuel Berg
2022-12-10 16:28                   ` Mutation - do you understand it really? (was: Closures - do you understand them well?) Stefan Monnier via Users list for the GNU Emacs text editor
2022-12-10 18:29                     ` Mutation - do you understand it really? Michael Heerdegen
2023-01-18 10:58                       ` Emanuel Berg
2023-01-19 13:59                         ` Michael Heerdegen
2023-01-19 17:47                           ` [External] : " Drew Adams
2022-12-11  2:24                   ` Closures - do you understand them well? Michael Heerdegen
2022-12-11  9:13                     ` Tassilo Horn
2022-12-10  2:26           ` Emanuel Berg
2022-12-10 17:20             ` [External] : " Drew Adams
2022-12-10 18:02               ` Iteration macros (was: [External] : Re: Closures - do you understand them well?) Stefan Monnier via Users list for the GNU Emacs text editor
2022-12-10 20:38                 ` Drew Adams
2023-01-18 11:10                   ` Emanuel Berg
2023-01-18 11:08                 ` Emanuel Berg
2022-12-21 23:53               ` [External] : Re: Closures - do you understand them well? Emanuel Berg
2022-12-09  3:43         ` Emanuel Berg
2022-12-09  4:01           ` Michael Heerdegen
2022-12-09  4:38             ` tomas
2022-12-09  5:37               ` Emanuel Berg
2022-12-09 16:55                 ` Michael Heerdegen
2022-12-10  4:52             ` Emanuel Berg
2022-12-08 19:44 ` Eric Abrahamsen
2022-12-08 20:11   ` Emanuel Berg
2022-12-08 20:53   ` Michael Heerdegen
2022-12-08 23:25     ` Michael Heerdegen
2022-12-09 16:50       ` Eric Abrahamsen
2022-12-09 18:48         ` Emanuel Berg
2022-12-09 19:25         ` Michael Heerdegen
2022-12-11 18:42           ` Eric Abrahamsen
2023-01-18 12:08             ` Emanuel Berg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).