[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Closures - do you understand them well?
From: |
Michael Heerdegen |
Subject: |
Closures - do you understand them well? |
Date: |
Thu, 08 Dec 2022 16:36:12 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) |
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.
- Closures - do you understand them well?,
Michael Heerdegen <=
- RE: [External] : Closures - do you understand them well?, Drew Adams, 2022/12/08
- Re: [External] : Closures - do you understand them well?, Michael Heerdegen, 2022/12/08
- RE: [External] : Closures - do you understand them well?, Drew Adams, 2022/12/08
- RE: [External] : Closures - do you understand them well?, Drew Adams, 2022/12/08
- Re: [External] : Closures - do you understand them well?, Michael Heerdegen, 2022/12/08
- RE: [External] : Closures - do you understand them well?, Drew Adams, 2022/12/08
- Re: [External] : Closures - do you understand them well?, Emanuel Berg, 2022/12/10
- RE: [External] : Closures - do you understand them well?, Drew Adams, 2022/12/08
Re: Closures - do you understand them well?, Tassilo Horn, 2022/12/08