Warning: this is an htmlized version!
The original is here, and
the conversion rules are here.
;; This file:
;;   http://anggtwu.net/elisp/pcase-tests.el.html
;;   http://anggtwu.net/elisp/pcase-tests.el
;;          (find-angg "elisp/pcase-tests.el")
;; Author: Eduardo Ochs <eduardoochs@gmail.com>
;;
;; (defun e () (interactive) (find-angg "elisp/pcase-tests.el"))
;; (find-es "emacs" "pcase-quickref")

;; https://www.emacswiki.org/emacs/PatternMatching

(defun oddp (n) (= (mod n 2) 1))

(defun pow-fast (x n)
  (pcase `(,x ,n)
    (`(,x 0) 1)
    ((and (let (pred oddp) n) `(,x ,n))
     (* x (pow-fast (* x x) (/ n 2))))
    (`(,x ,n)
     (pow-fast (* x x) (/ n 2)))))

(pow-fast 2 5)
(pow-fast 2 4)
(pow-fast 2 0)
;; -> 32


(defun pow-fast (x n)
  (pcase `(,x ,n)
    (`(,x 0)                            (list :case1))
    ((and (let (pred oddp) n) `(,x ,n)) (list :case2 x n))
    (`(,x ,n)                           (list :case3 x n))))

(defun pow-fast (x n)
  (pcase `(,x ,n)
    (`(,x 0)                            (list :case1 x n))
    ((and (let (pred oddp) n) `(,x ,n)) (list :case2 x n))
    (`(,x ,n)                           (list :case3 x n))
    ))

(defun pow-fast (x n)
  (pcase `(,x ,n)
    ((and (let (pred oddp) n) `(,x ,n)) (list :case2 x n))
    ))

(pcase '(2 5)
  ((and (let (pred oddp) 7)
	`(,x ,n))
   (list :case2 x n))
  )

(defun oddp (n) (= (mod n 2) 1))

(pcase '(2 5)
  ((and (let (and (pred oddp) `,c) 7)
	`(,a ,b))
   (list :case2 a b c))
  )

(pcase '(3 4) ((and (let `,a 2) `(,b ,c)) (list :abc a b c)))
(pcase '(3 4) ((and (let   a 2) `(,b ,c)) (list :abc a b c)))
(pcase '(2 3) ((and `(,a ,b) (let c 2)) (list :abc a b c)))



x
n



  (pcase '(2 5)
    (`(,x 0) 1)
    ((and (let (pred oddp) n) `(,x ,n))
     (* x (pow-fast (* x x) (/ n 2))))
    (`(,x ,n)
     (pow-fast (* x x) (/ n 2))))




            (pcase '(20 30) (`(,a ,b) (list :ab a b)))
(find-eppm '(pcase '(20 30) (`(,a ,b) (list :ab a b))))




(find-elinode "")
(find-elnode "")


(oddp 5)
(oddp 4)





(setq my-sexp '(find-eev2021video "2:34" "foo" "bar"))

(pcase my-sexp (`(,a ,b . ,c) (list a b c)))
(pcase my-sexp ((and
		 `(,a ,b . ,c)
		 (guard (symbolp a))
		 (guard (stringp b))
		 )
		(list a b c)))



(pcase '(10 20 40)
  (`(,a ,b ,c)
   (list :abc a b c)))

(pcase '(10 20 40)
  ((and `(,a ,b ,c))
   (list :abc a b c)))

(pcase '(10 20 40)
  ((and `(,a ,b ,c)
	(guard (< a 15)))
   (list :abc a b c)))

(pcase '(10 20 40)
  ((and `(,a ,b ,c)
	(guard (< a 5)))
   (list :abc a b c)))



(pcase '(10 20) (     `(,a ,b)                   (list :ab a b)))
(pcase '(10 20) ((and `(,a ,b))                  (list :ab a b)))
(pcase '(10 20) ((and `(,a ,b) (guard (< a  5))) (list :ab a b)))
(pcase '(10 20) ((and `(,a ,b) (guard (< a 15))) (list :ab a b)))
(pcase '(10 20) ((and `(,a ,b) (let (guard (< a 5)) c)) (list :ab a b)))

(pcase '(10 20) (`,a  (list a)))
(pcase '(10 20) (let (`,a) 30))
(pcase '(10 20) (let (pred oddp) 30))


‘(let PATTERN EXPR)’



(pcase-let* ((`(,a ,b) '(10 20))
	     ((guard (< a 5)))
	     (c (+ a b)))
  (list a b c))


(pcase '(10 20 40)
  ((and `(,a ,b ,c)
	(guard (< a 5)))
   (list :abc a b c)))



  (and `(,a ,b ,c)
       (let d (+ a b))))



;; Local Variables:
;; coding:  utf-8-unix
;; End: