Algebraic data types: Difference between revisions

m
Emacs Lisp: Fix formatting, add more notes on pcase.
m (Emacs Lisp: Fix formatting, add more notes on pcase.)
Line 576:
=={{header|Emacs Lisp}}==
 
The <code>pcase</code> syntaxmacro was added in Emacs 24.1. It's auto-loaded, so there's no need to add <code>(require 'pcase)</code> to your code.
 
<lang lisp>(defun rbt-balance (tree)
(defun rbt-balance (tree)
(pcase tree
(`(B (R (R ,a ,x ,b) ,y ,c) ,z ,d) `(R (B ,a ,x ,b) ,y (B ,c ,z ,d)))
Line 606 ⟶ 605:
(dotimes (i 16)
(setq s (rbt-insert (1+ i) s)))
(pp s))</lang>
</lang>
Output:
 
Anonymous user