Finish up episode 7
This commit is contained in:
parent
701d3d912c
commit
1ec652e6f4
|
@ -310,7 +310,8 @@ digraph {
|
|||
(cdr x9)
|
||||
#+END_SRC
|
||||
|
||||
* Episode 6 - Property & Association Lists
|
||||
* DONE Episode 6 - Property & Association Lists
|
||||
CLOSED: [2022-06-13 Mon 10:38]
|
||||
** I have an idea
|
||||
- Develop *FG42* on stream
|
||||
- I'll announce the date and time on:
|
||||
|
@ -413,3 +414,78 @@ digraph {
|
|||
- https://www.gnu.org/software/emacs/manual/html_node/elisp/Association-Lists.html
|
||||
- https://www.gnu.org/software/emacs/manual/html_node/elisp/Plist-Access.html
|
||||
- https://www.gnu.org/software/emacs/manual/html_node/elisp/Plists-and-Alists.html
|
||||
|
||||
* Episode 7 - Basic Loops
|
||||
** About previous episode
|
||||
- Duplicate keys in an association list
|
||||
- ~eval-defun~
|
||||
** While
|
||||
- Form:
|
||||
#+BEGIN_SRC emacs-lisp
|
||||
(while CONDITION
|
||||
...body...)
|
||||
#+END_SRC
|
||||
- Loops and evaluates ~body~ as long as the ~CONDITION~ evaluates to true.
|
||||
- It always evaluats to the value of the ~CONDITION~ which will be false aaaaall the time.
|
||||
- We need to explicitly manage the condition.
|
||||
- Example:
|
||||
#+BEGIN_SRC emacs-lisp
|
||||
(let ((foo 1))
|
||||
(while (< foo 10)
|
||||
(message ">> %s" foo)
|
||||
(setq foo (+ 1 foo))))
|
||||
|
||||
(let ((foo '(bar baz)))
|
||||
(while foo
|
||||
(message ">> %s" (car foo))
|
||||
(setq foo (cdr foo))))
|
||||
#+END_SRC
|
||||
|
||||
** dolist
|
||||
- It's a macro
|
||||
- Form:
|
||||
#+BEGIN_SRC emacs-lisp
|
||||
(dolist (element list [result])
|
||||
...body...)
|
||||
#+END_SRC
|
||||
|
||||
- Evaluates the ~body~ with ~element~ set to the CAR of ~list~ on each iteration
|
||||
- At the ends evaluates ~result~ and return the evaluation result (if ~result~ is provided)
|
||||
- Example:
|
||||
#+BEGIN_SRC emacs-lisp
|
||||
(let ((foo '(9 8 7 6 5 4)))
|
||||
(dolist (x foo (+ 10 1))
|
||||
(message ">> %s" x)))
|
||||
|
||||
|
||||
(let ((foo '(9 8 7 6 5 4)))
|
||||
(macroexpand-1
|
||||
'(dolist (x foo 10)
|
||||
(message ">> %s" x))))
|
||||
#+END_SRC
|
||||
|
||||
** dotimes
|
||||
- It's a macro too
|
||||
- Form:
|
||||
#+BEGIN_SRC emacs-lisp
|
||||
(dotimes (var number)
|
||||
...body...)
|
||||
#+END_SRC
|
||||
- It's similar to ~dolist~ but iterates ~number~ of times
|
||||
- ~var~ in will contains the number of current iteration
|
||||
- Example:
|
||||
#+BEGIN_SRC emacs-lisp
|
||||
(let ((foo 10))
|
||||
(dotimes (x foo)
|
||||
(message ">> %s" x)))
|
||||
|
||||
|
||||
(let ((foo 10))
|
||||
(macroexpand-1
|
||||
'(dotimes (x foo)
|
||||
(message ">> %s" x))))
|
||||
#+END_SRC
|
||||
|
||||
* Episode 8 - More Loops
|
||||
** Recursion
|
||||
** Functional style loops
|
||||
|
|
Loading…
Reference in New Issue