Add episode 8 to the videos.org

This commit is contained in:
Sameer Rahmani 2022-07-12 15:53:46 +01:00
parent 46932dcacd
commit d0a2434679
1 changed files with 68 additions and 1 deletions

View File

@ -415,7 +415,8 @@ CLOSED: [2022-06-13 Mon 10:38]
- 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
* DONE Episode 7 - Basic Loops
CLOSED: [2022-07-09 Sat 10:31]
** About previous episode
- Duplicate keys in an association list
- ~eval-defun~
@ -488,4 +489,70 @@ CLOSED: [2022-06-13 Mon 10:38]
* Episode 8 - More Loops
** Recursion
- A *Recursive* function, is a function that defines in terms of itself
- Easy to implement
- But should be careful with it to aviod infinit loops
*** Example
#+BEGIN_SRC emacs-lisp
(defun foo (int)
(print int)
(when (> int 0)
(foo (- int 1))))
(foo 10)
#+END_SRC
** Functional style loops
*** Mapping functions Family
- ~mapcar~
#+BEGIN_SRC emacs-lisp
(mapcar #'1+ '(1 2 3 4 5))
(mapcar (lambda (x) (* x x))
'(1 2 3 4))
#+END_SRC
- ~mapc~
#+BEGIN_SRC emacs-lisp
(mapc #'1+ '(1 2 3 4 5))
(mapc #'print '(1 2 3 4 5))
#+END_SRC
- ~map-concat~
#+BEGIN_SRC emacs-lisp
(mapconcat (lambda (x)
(format "[%s]" x))
'(1 2 3 4 5)
" <|> ")
#+END_SRC
*** Seq module
A collection of handy functions that operate on ~sequences~.
- ~seq-reduce~
#+BEGIN_SRC emacs-lisp
(require 'seq)
(seq-reduce
(lambda (acc x)
(+ acc x))
'(1 2 3 4)
0)
#+END_SRC
- ~seq-filter~
#+BEGIN_SRC emacs-lisp
(seq-filter (lambda (x) (< x 10))
'(8 12 22 9))
#+END_SRC
- ~seq-partition~
#+BEGIN_SRC emacs-lisp
(seq-partition '(a b c d e f) 2)
#+END_SRC
- ~seq-min~, ~seq-max~
* Episode 9 - Basics of Macros